create tables from command file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • picaza

    #1

    create tables from command file

    hi,
    please correct my terminology if it is incorrect but i am trying to
    create a number of tables by writing an sql script/batch file and using
    the command:

    mysql -D myDB -u myname --password=myPass <
    scriptname.sql > err.sql 2>&1

    and i am getting errors. the book i am using doesnt seem to cover this
    topic well but i think i must be doing something silly that is
    preventing the script from running successfully.

    i have tried using and not using the single quotes in the following
    examples. here is the error i get:

    +++++++++++++++ ++++
    ERROR 1064 at line 15: You have an error in your SQL syntax. Check the
    manual that corresponds to your MySQL server version for the right
    syntax to use near ''User'
    (
    'userId' varchar(25) not null primary key,
    'la

    +++++++++++++++ ++++

    here are two entries in the script, one w/ quotes one w/o:

    CREATE TABLE 'User'
    (
    'userId' varchar(25) not null primary key,
    'lastName' varchar(25) not null,
    'firstName' varchar(25) not null,
    'organization' varchar(50) not null,
    'phone' char(12),
    'email' varchar(25),
    'lastLogin' datetime,
    );

    CREATE TABLE Cookie
    (
    sessionId char(20),
    userId varchar(25) not null references User(UserId),

    );

    +++++++++++++++ ++++++++
    any thoughts will be appreciated.
    tia,
    peter






  • Bill Karwin

    #2
    Re: create tables from command file

    picaza wrote:[color=blue]
    > CREATE TABLE 'User'[/color]

    MySQL uses backticks (`) to delimit identifiers. Otherwise using
    identifiers that clash with SQL reserved words confuses the parser.

    Regards,
    Bill K.

    Comment

    • picaza

      #3
      Re: create tables from command file

      [color=blue]
      > MySQL uses backticks (`) to delimit identifiers. Otherwise using
      > identifiers that clash with SQL reserved words confuses the parser.
      >[/color]
      thanks bill,
      i will go try it out now.
      seeya,
      peter

      Comment

      Working...