...

View Full Version : creating a tabel in 5.5



sherlockturtle
10-14-2011, 11:11 PM
I have just started using sql but when i try to use this code it does not work.

CREATE TABLE users
(
id INT IDENTITY(1,1),
username VARCHAR(20) UNIQUE,
password VARCHAR(20) ,
email VARCHAR(50)
);

I just dont understand how to make a tabel in 5.5 m using the command line client.

Old Pedant
10-14-2011, 11:35 PM
IDENTITY is SQL Server, not MySQL.

Read the docs: http://dev.mysql.com/doc/refman/5.5/en/create-table.html



CREATE TABLE users
(
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(20) UNIQUE,
password VARCHAR(20),
email VARCHAR(50)
);


NOTE: In MySQL, the AUTO_INCREMENT field *must* be a key, so it's common to make it the PRIMARY KEY, though it doesn't have to be. But if you will use it as a foreign key in other tables, then making it PRIMARY is best practice.

sherlockturtle
10-15-2011, 12:16 AM
Your link does not work. and was identity the only thing that was wrong?

oracleguy
10-15-2011, 12:27 AM
Your link does not work. and was identity the only thing that was wrong?
He gave you the SQL statement that would work you can compare that with yours to see the differences. He changed the identity to auto increment and made it the primary key.

sherlockturtle
10-15-2011, 12:31 AM
thanks both of you.

Old Pedant
10-15-2011, 02:09 AM
I just retested that link. It worked fine.

But just in case, here it is in plain text:

http://dev.mysql.com/doc/refman/5.5/en/create-table.html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum