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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading text SQL files

Status
Not open for further replies.

flawless69

Programmer
May 31, 2002
86
US
Is it possible to import a text file containing SQL statements into MySQL? I don't mean to import data, I just want to insert a ton of SQL statements I made with Perl. --Derek

"Fear not the storm for this is where we grow strong."
 
(assuming a Unix-type OS)

If your file of SQL statements is "foo.sql", and you want to insert the records in a database named "bar" then from the command prompt:

cat foo.sql | mysql bar [mysql options]

will do it. It might take a while.

Another way to do the same thing that is more efficient is to use MySQL's "LOAD DATA" statement. Using LOAD DATA with the right options, you can load a CSV file into your table. ______________________________________________________________________
TANSTAAFL!
 
or from a mysql prompt type \.path/to/foo.sql where foo.sql contains all of the commands and data :) ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top