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 |
Assuming that you are an End User How to find that in the payment Batch some of the Invoice was Missing To pay How to find That??
What is a named program unit?
What is a table index?
How to connect ms access to oracle servers?
What is oracle in java?
when loggined as SYSTEM,how to display all the users of database using sql query?
What do database buffers contain?
What is oracle analytical function?
Display the order number and the number of months since the order was shipped for all orders that have been shipped in the last year (365 days). (Hint: Unshipped orders will have a null value).
what are the disadvantages of hierarchial database over RDBMS?
What is the recommended interval at which to run statspack snapshots, and why?
What is meant by an index?