setting the primary key

Go down

setting the primary key

Post by jeeva on 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

View user profile

Back to top Go down

Re: setting the primary key

Post by rohit_1000r on 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

View user profile

Back to top Go down

Re: setting the primary key

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

This ll also work.

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

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

View user profile http://unixcpp.forumotion.com

Back to top Go down

Re: setting the primary key

Post by jeeva on 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

View user profile

Back to top Go down

Re: setting the primary key

Post by jennyinhere on 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 : 30

View user profile

Back to top Go down

Re: setting the primary key

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

@jeeva
sql> desc <tablename>;

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

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

View user profile

Back to top Go down

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