Hi All,

How to add a candidate key in a table in SQl??

Please Help.

Thanks.

Recommended Answers

All 5 Replies

m not really sure but i think candidate key is the column which qualifies to be a primary key.
so u can set this column as primary key if u wish to at a later date.
but i dont think you can assign a candidate key

What I actually want is to make one key of my table as candidate key.
I used keyword UNIQUE also but I was not able to accomplish the task.
Pls suggest.

set Primary key.

set Primary key.

But Sir, I don't want to set the key as primary key..

Actually, I am sorry not to tell my problem in detail..

Specifically, I have a table with enrolno as primary key and I want to make classid As Candidate key, because I want to reference ClassID from a foreign key of another table. For that when I use the query to set FOREIGN KEY constraint that refers to the classid of this table,i get the error asking for classid to be either primary or candidate key..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.