Unix C++
Would you like to react to this message? Create an account in a few clicks or log in to continue.

setting the primary key

5 posters

Go down

setting the primary key Empty setting the primary key

Post by jeeva Thu Mar 18, 2010 5:16 pm

how to set the primary key of a table that is already created....!!!!

jeeva

Posts : 50
Points : 93
Join date : 2010-03-04

Back to top Go down

setting the primary key Empty Re: setting the primary key

Post by rohit_1000r Thu Mar 18, 2010 5:35 pm

for adding a primary key constraint on an existing table here is the syntax

ALTER TABLE <Tablename> ADD CONSTRAINT <constraint name> PRIMARY KEY(<Column Name>);

rohit_1000r

Posts : 4
Points : 4
Join date : 2010-03-09

Back to top Go down

setting the primary key Empty Re: setting the primary key

Post by Christopher Thu Mar 18, 2010 5:43 pm

This ll also work.

Code:
ALTER TABLE <TABLENAME> MODIFY(<FIELDNAME> <TYPE> PRIMARY KEY);
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

setting the primary key Empty Re: setting the primary key

Post by jeeva Thu Mar 18, 2010 5:50 pm

how can we identify an existing primary key!!!

jeeva

Posts : 50
Points : 93
Join date : 2010-03-04

Back to top Go down

setting the primary key Empty Re: setting the primary key

Post by jennyinhere Fri Mar 19, 2010 3:50 pm

@christopher

Wat is the "type" in alter command

jennyinhere

Posts : 24
Points : 30
Join date : 2010-02-26
Age : 35

Back to top Go down

setting the primary key Empty Re: setting the primary key

Post by Mahee Fri Mar 19, 2010 3:57 pm

@jeeva
sql> desc <tablename>;

@jenny
datatype (number or varchar2)....
Mahee
Mahee

Posts : 29
Points : 233
Join date : 2010-03-03
Location : Haldia

Back to top Go down

setting the primary key Empty Re: setting the primary key

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum