Loading Schemata From *.sql Files Into MySQL

I have recently been working a lot with MySQL stored procedures. I tend to write them up first in a text editor - textpad or vim, and then import them into MySQL for testing etc. I have always cut and then pasted the code into the command line - how archaic!!! There must, and is a better way to import *.sql files into MySQL without having to cut and paste schemata in such a poor way - MySQL’s SOURCE command. For importing my_file.sql from your /home directory simply type:

mysql> SOURCE /home/my_file.sql

Hopefully this entry will serve to remind me in the future!

As an addendum, it is strange that the SOURCE command is not documented in MySQL’s online documentation - see this search with google. Also the command line help turns nothing up…

mysql> HELP SOURCE;
Nothing found
Please try to run 'help contents' for a list of all accessible topics

Strange…

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blogmarks
  • co.mments
  • del.icio.us
  • digg
  • Fark
  • Furl
  • Reddit
  • Spurl
  • TailRank
  • YahooMyWeb

About this entry