SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: problem with simple SQL command
-
Feb 11, 2002, 15:07 #1
- Join Date
- Feb 2002
- Posts
- 1
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
problem with simple SQL command
I am new at this.
I am trying to execute this command:
CREATE TABLE table_name (
-> column_1_name column_1_type column_1_details,
-> column_2_name column_2_type column_2_details,
-> );
from a mysql> prompt and am getting the following error:
ERROR 1064: You have an error in your SQL syntax near 'column_1_type column_1_details,
column_2_name column_2_type column_2_details' at line 2
I'm copying the commands directly from a web page and I've looked over the consistancy of the text, but I can't figure it out, obviously.
Any information would be much appreciated.
Thanks.
Rob
-
Feb 11, 2002, 16:10 #2
Here is a real world example:
Code:CREATE TABLE User ( ID int(11) NOT NULL auto_increment, Name varchar(30) NOT NULL, Email varchar(200) NOT NULL, PRIMARY KEY (ID) );
Hope this gets you going.
Cheers.
-
Feb 11, 2002, 16:10 #3
- Join Date
- Jun 2001
- Location
- Oklahoma
- Posts
- 3,392
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That's because that is giving you a layout, not the exact commands. For example, column_1_type can be either varchar(), char(), text, int, blob, date, et cetera. column_1_details can be primary key, not null, unique, et cetera.
So a general command would be something like:Code:-> CREATE TABLE table_name ( -> column_1_name varchar(30) not null primary key, -> column_2_name text not null);
Go to the documentation at MySQL.com and you'll be able to easily find the syntax to be used when creating tables.
-ColinColin Anderson
Ambition is a poor excuse for those without
sense enough to be lazy.
Bookmarks