02 October 2009
0 SQL Tutorial - Loading data from a text file
SQL Tutorial - SQL Tip - Loading data from a text file
How can I load data into table from a .txt file?
You can load data into table from a .txt file using the below command.
LOAD DATA LOCAL INFILE <.txt file >
INTO TABLE <table_name> FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
The data file should have the fields terminated by ‘,’ and lines terminated by '\r\n'; INTO TABLE <table_name> FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
For Example
Say, the required input file "user.txt" is in the location C:\
LOAD DATA LOCAL INFILE 'C:\\user.txt'
INTO TABLE user_name FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
INTO TABLE user_name FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
Subscribe to:
Post Comments (Atom)
0 comments:
Please give your valuable comments.