Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Other Scripting Languages (http://www.programmingforums.org/forum39.html)
-   -   primary key (http://www.programmingforums.org/showthread.php?t=7084)

darkone916 Nov 19th, 2005 12:21 PM

primary key
 
ahm... i have been learning MySQL lately 'cause i want to use them in webpages with php.
but there is just one simple thing that i couldn't figure how to do it:

How do you set a primary key in one of the fields? :confused:

Thank You!

OpenLoop Nov 19th, 2005 1:06 PM

It's been a while since i did sql but i believe that if you set a field to "not null" and "unique" it becomes a primary key.
:

CREATE TABLE mytbl(custname CHAR(20) NOT NULL UNIQUE);

darkone916 Nov 19th, 2005 1:15 PM

Thanks A lot! And please don't think that i was just been lazy, i did do some googling and searching in the forum...

DaWei Nov 19th, 2005 2:14 PM

:

CREATE TABLE mytbl
(
custname CHAR(20) NOT NULL,
...
...
...
PRIMARY KEY (custname),
...
...
);

is an alternative I use.


All times are GMT -5. The time now is 1:08 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC