Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL txt converting

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Does anyone know how to convert from the a text file that contains commands to make a new database (ie "customer.txt") into an SQL file. It's rumored there is a command, but I can't find it.
 
Just use the &quot;mysql&quot; binary using the &quot;<&quot; operator.

eg.
/usr/bin/mysql -u someone -p database_name < customer.txt

That'll do it.

brendanc@icehouse.net
 
This is what I did:
First I created the database with:

CREATE TABLE ptree2000 (rank INT, firstname VARCHAR(25), lastname VARCHAR(20), age INT, location VARCHAR(30), racetime TIME);

Then I loaded the data into it with:

LOAD DATA LOCAL INFILE 'ptree2000.csv' INTO TABLE ptree2000 FIELDS TERMINATED BY ',';

FYI: My source data was an Excel file that I had saved into CSV format.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top