what is the use of composite key constraint?

Answer Posted / srikanth

A composite key is used to club primary key for more than
once column.

PRIMARY KEY(<<COLUMN1>>,<<COLUMN2>>....<<COLUMNN>>)

But the disadvantage is that it will allow duplicates for
any one of the fields.

Example:

CREATE TABLE Example1
(Id INT NOT NULL,Pername VARCHAR(20) NULL,Phno INT NOT NULL
PRIMARY KEY(Id,Phno)
)

Command(s) completed successfully.

INSERT INTO Example1
VALUES(1,'sri',1111)

(1 row(s) affected)

INSERT INTO Example1
VALUES(1,'sri',6666)

(1 row(s) affected)

SELECT * FROM Example1

Id Pername Phno
1 sri 1111
1 sri 6666

As you can see that it is allowing same Id.

Basically Composite Key will take all the fields defined as
a group.So it is least bothered about any one of the field.

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How different is ms access and oracle?

537


What is ceil and floor in oracle?

565


How to convert times to characters in oracle?

599


How to drop an existing table in oracle?

586


What happens to the current transaction if a ddl statement is executed?

570






How to use "in" parameter properly?

609


How to estimate disk space needed for an export job?

556


What is open database communication (odbc) in oracle?

538


How to use windows user to connect to the server?

528


Explain oracle’s system global area (sga).

613


Please explain drop constraint oracle?

621


What are the major difference between truncate and delete?

511


What is user managed backup in Oracle?

605


What are the types of partitions in oracle?

534


How to write a query with an inner join in oracle?

558