MySQL Forums
Forum List  »  Newbie

Re: Import Data from txt/csv into MySQL Table
Posted by: Mindaugas Brazenas
Date: May 27, 2007 12:42PM


It is really easy to import data from *.txt.
OK lets see what we have... and we have a quick tutorial how to do it! :)

1. create rs.txt file and put some date into it:

1 Jhon 22
2 Mike 18
3 Peter 32
4 Tom 19

note that the fields must be separate by tab

2. create the table, that will be filled with content form rs.txt
mysql> create table data_table (id int, name varchar(20), age int);

3. and fill it!
mysql> load data local infile "rs.txt" into table data_table;

P.S. to have this work successfully make sure that rs.txt is located at
'MySQL Sverver 6.0\bin'

4. let's see what we have:
mysql> select * from data_table;
[there is a nice table]

5. feel free to ask if you failed to get wanted result :)

Good luck!

Mindaugas Brazenas

Options: ReplyQuote

Written By
Re: Import Data from txt/csv into MySQL Table
May 27, 2007 12:42PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.