Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2004
    Location
    israel
    Posts
    7

    Unanswered: can i use batch files instead of a line command

    such as:
    CREATE TABLE Customers (Customer_id INT NOT NULL PRIMARY KEY...)
    Can i write it in an editor, save it as a batch file and than, rather then write the above command, simply run the batch ?
    If the answer is positive, can anyone explain me how excactly i do it:
    run from inside the ide or outside? Where do i save the file? What extension has the file ? What syntax?
    Thanks !

  2. #2
    Join Date
    Aug 2003
    Location
    Reston, VA
    Posts
    59

    Yes, you can...

    If I understand you correctly, you want to read you SQL from a file. That's simple. Simply put the SQL syntax in a text file using a normal editor. If you have multiple SQL statements, you just need to put a \n character at the end.

    Sample

    SELECT * FROM table1;
    SELECT * FROM table2;

    You can use any file extension you like, but I use a .sql naming convention. You can run this at the mysql prompt like....'mysql mydatabasename < mysqlstatements.sql'.

    hope this helps...

  3. #3
    Join Date
    Jul 2003
    Posts
    73
    You can also run the file when connected to the MySQL client as follows:

    Code:
    SOURCE mysqlstatements.sql
    Joel Dixon
    Analyst Programmer
    Melbourne, Australia

  4. #4
    Join Date
    Oct 2004
    Location
    israel
    Posts
    7

    Tanks a lot !

    I'll use your aid !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •