If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Need table creation SQL syntax check

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-26-04, 00:59
awohld awohld is offline
Registered User
 
Join Date: Jan 2004
Posts: 11
Question 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.
Reply With Quote
  #2 (permalink)  
Old 01-26-04, 07:35
watchachi watchachi is offline
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old 01-26-04, 07:46
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 01-27-04, 01:23
awohld awohld is offline
Registered User
 
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!!!!

Quote:
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
Reply With Quote
  #5 (permalink)  
Old 01-27-04, 05:54
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
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?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 01-29-04, 01:08
awohld awohld is offline
Registered User
 
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.

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

which book is it?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On