Re: how to create secondary key!!
От | Josh Berkus |
---|---|
Тема | Re: how to create secondary key!! |
Дата | |
Msg-id | web-1797585@davinci.ethosmedia.com обсуждение исходный текст |
Ответ на | how to create secondary key!! ("Nelson Yong" <nelsonyong@ipmuda.com.my>) |
Ответы |
Postgres and Sybase
|
Список | pgsql-novice |
Nelson, > What i call the Secondary key is when i want two or more fields > become > key eg. Order Table can be more than one or more transaction, i > assign > order no. and record no. as key. The Order no. call primary key and > the > Record no. as secondary key. I'm afraid that's incorrect. What you have is a "two-column primary key." There is no "secondary key". Here's how you create one: create table order_detail ( order_no INT NOT NULL REFERENCES orders(order_no), record_no INT NOT NULL, item_no INT NOT NULL REFERENCES inventory(item_no), quantity NUMERIC NOT NULL, comment TEXT, CONSTRAINT order_detail_PK PRIMARY KEY (order_no, record_no) ); Got it? Read the "CREATE TABLE" documentation for more detail. -Josh Berkus P.S. To reiterate: There are Primary Keys, Candidate Keys, Surrogate Keys, and Foreign Keys, but no "Secondary Keys".
В списке pgsql-novice по дате отправления: