Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2004
    Posts
    11

    Question Unanswered: Need table creation SQL syntax check

    I'm trying to insert a table into my MySQL data base wit the following command:

    server:/home/webpage$ mysql -ppassword database < table.sql


    The Error I get is this:

    ERROR 1064 at line 1: You have an error in your SQL syntax near 'unique default
    nextval('commentidtest'),
    commentpage varchar(255),
    poster' at line 2



    My table.sql statement looks like this:

    create table comment (
    comment_id int primary key unique default nextval('comment_id_test'),
    comment_page varchar(255),
    poster_email varchar(50),
    poster_name varchar(60),
    subject varchar(60),
    comment text,
    date abstime,
    poster_notify bool
    );


    Can anyone tell me what's wrong with my syntax?

    Thanks for the help.

  2. #2
    Join Date
    Jan 2004
    Posts
    17
    I had a problem that looked like this.. so i
    put the primary key definition alone at the end..

    create table(test varchar(50), primary key(test));

    i dont know if this will work with you, but it worked with me.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the feature for the primary key i believe you are looking for is called auto_increment in mysql

    abstime should be datetime or date or time or timestamp

    bool should be tinyint or char(1) or enum

    you were okay with the varchar, though

    i suggest you have a look at the available Column Types
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Jan 2004
    Posts
    11

    Thumbs up

    Okay, thanks. That was actually a postgre sql that my script came with and the author said I could use it with MySQL. I thought since it was SQL it would be standard. I just read my first SQL book, SAMS Teach Yorself SQL in 10 Min, and realized it's all not standard.

    Thanks again for the help!!!!

    Originally posted by r937
    the feature for the primary key i believe you are looking for is called auto_increment in mysql

    abstime should be datetime or date or time or timestamp

    bool should be tinyint or char(1) or enum

    you were okay with the varchar, though

    i suggest you have a look at the available Column Types

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    That was actually a postgre sql that my script came with and the author said I could use it with MySQL.
    what??!! the author is flat out wrong, unless he/she qualified the remark with a condition like "should work in mysql with minor alterations"

    i would be careful with anything else in the book, then

    which book is it?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Jan 2004
    Posts
    11
    Ooops, that wasn't really clear. It was the author of a perl script called SSICOMMENT, not the author of a book.

    Originally posted by r937
    i would be careful with anything else in the book, then

    which book is it?

Posting Permissions

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