A suggested way of doing this would be to use phpMyAdmin as a tool
of choice. If you have phpMyAdmin installed as part of your Web
hosting plan, you should be able to access phpMyAdmin through your
control panel. Once you're in phpMyAdmin, you will notice on the
left hand side that you have a list of datbases and/or tables. You
will need to select the table that contains the field you wish to
set as a primary key. Once you open the table, you will see a list
of fields in the table. Place a check in the checkbox next to the
field you wish to set as a primary key. Then, navigate to the bottom
of the list where you will see some little icons. Click on the one
with the "gold key". This should do the trick for you.
Otherwise, you can see if your mySQL admin area has some tool or
functionality that will let you "Generate Create Table Script",
which allows you to generate the following sample code for a table
without having to type it all in again:
CREATE TABLE `property`(
propertyid int(7) NOT NULL AUTO_INCREMENT,
username varchar(10) NOT NULL,
pass varchar(10) NOT NULL,
firstName varchar(25) NOT NULL,
lastName varchar(25) NOT NULL,
PRIMARY KEY (propertyid)
);
IMPORTANT!!! Read the entire following paragraph before doing
anything!!!
After the script is generated, you can copy it to your clipboard and
paste it into a text file just to be safe. Then, delete the table
you wish to place a primary key into. That's right, delete it
because you're going to replace the deleted table with the newly
formatted table (which has your primary key in it) by pasting
the "Create Table" script into an "Execute SQL Statement" textarea
box (assuming you have one somewhere). Submit the information. SQL
generates the table for you! I'm sure there are other ways, but I am
still a beginner at SQL. Good luck!
If you have anymore questions, I'm glad to help!
--- In [email protected], onurdyh <[EMAIL PROTECTED]> wrote:
>
>
> hi everybody I have problem and if you help me I glad.I have
created a table without primary key but now I want to add a primary
key to the table how can I make it??
> thankss
>
>
>
> ---------------------------------
>
>
>
>
>
>
> ---------------------------------
> Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, &
more on new and used cars.
>
> [Non-text portions of this message have been removed]
>
The php_mysql group is dedicated to learn more about the PHP/MySQL web database
possibilities through group learning.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php_mysql/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/