Page 1 of 1

Term Confusion!

Posted: Thu Aug 02, 2007 3:29 am
by cashflowtips
i want to create a table using mysql by following the example given in a book but i facing this problem...

Code: Select all

CREATE TABLE user_session {
"id"SERIAL PRIMARY KEY NOT NULL
}
what i dont understand is what does it mean by SERIAL PRIMARY KEY? so, what kind of datatype use for id?

Re: Term Confusion!

Posted: Thu Aug 02, 2007 3:55 am
by onion2k
cashflowtips wrote:i want to create a table using mysql by following the example given in a book but i facing this problem...

Code: Select all

CREATE TABLE user_session {
"id"SERIAL PRIMARY KEY NOT NULL
}
what i dont understand is what does it mean by SERIAL PRIMARY KEY? so, what kind of datatype use for id?
Serial used to be an alias for an auto incrementing BIGINT field. It's a Postgresql feature that MySQL added for compatibility. It's not mentioned in the MySQL manual any more though so I guess it's been dropped.

Posted: Thu Aug 02, 2007 4:02 am
by cashflowtips
so, can i use this "SERIAL" in normal MySQL...? how?

Posted: Thu Aug 02, 2007 4:06 am
by onion2k
cashflowtips wrote:so, can i use this "SERIAL" in normal MySQL...? how?
I wouldn't recommend using it even if the alias is still available. Define your tables properly using the data types set out in the MySQL manual.

Posted: Thu Aug 02, 2007 4:11 am
by cashflowtips
can u give me some example bcoz i never use postgresql before... from wut i notice, the command to connect to table is using pg_connect,pg_query and etc which i believed stand for postgresql... so how can i change it so that i can be used in normal mysql?

Posted: Thu Aug 02, 2007 4:19 am
by onion2k
There's millions of examples of how to use PHP with MySQL online. Use Google to find some. Better yet, use the PHP manual.

PS. We have a rule about using AOL speak (u, bcoz, wut). Don't use it.

Posted: Thu Aug 02, 2007 9:33 pm
by califdon
cashflowtips wrote:can u give me some example bcoz i never use postgresql before... from wut i notice, the command to connect to table is using pg_connect,pg_query and etc which i believed stand for postgresql... so how can i change it so that i can be used in normal mysql?
MySQL and Postgresql are two entirely different database engines, with their own variations of SQL language. Don't mix them up! Use one or the other!