what is the use of composite key constraint?
Answers were Sorted based on User's Feedback
Answer / deva
its used to create a primary keys based on two or more
columns in the particular table.
By the set, those should be unique.
| Is This Answer Correct ? | 14 Yes | 3 No |
Answer / 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 |
what are indexes..how many types of index's are there and what are they?
7 Answers Green Info Solutions, TCS,
if you ctreate table identity
How to export your own schema?
What is logical backup in oracle?
What is a OUTER JOIN?
How to change program global area (pga) in oracle?
Difference between varchar and varchar2 data types?
How to get a list of all user accounts in the database?
how to get last monday of a month?
src name sex a,male b,female c,male d,female Required output : male female a,b c,d tried pivot but was not successfull select * from src pivot (max(name) for sex in ('MALE','FEMALE'));
How many categories of data types?
what is the need of indexing topic in oracle? where do we use in a Java project? any other option other than using this to get the same result where we use indexing ?