|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
here I have a question,
can one table consists of 2 primary key ? thank you. |
|
#2
|
||||
|
||||
|
You can't have two primary keys in a single table.
Only one primary key is allowded in a single table. ------------------ SR - shiju.dreamcenter.net |
|
#3
|
|||
|
|||
|
i know one table can have 2 index keys but can't have 2 primary key. But in mysql how to add index key.
for example: State lookup table: (3 fields:country_id,state_id,statedesc) data: record 1('sg','st1','Happy State') record 1('sg','st2','Perfect State') record 1('sg','st3','Hello State') record 1('tw','st1','Apple State') record 1('tw','st2','Orange State') record 1('tw','st3','Star State') record 1('tw','st4','Bird State') I want to set country_id and state_id as index key. how to do ? thank you. |
|
#4
|
|||
|
|||
|
You can have a primary key consisting of two (or more) columns though. Have a look at http://www.mysql.com/Manual_chapter...ml#CREATE_TABLE
Hope this helps! Greetz, Peter [This message has been edited by WuzWuz (edited May 05, 2000).] |
|
#5
|
|||
|
|||
|
Make a composite primary key when you create the table.
> create table state_lookup( > country_id varchar(10) not null, > state_id varchar(10) not null, > statedesc varchar(50), > primary key(country_id, state_id)); |
|
#6
|
|||
|
|||
|
Thanks for your helps
|
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > two primary key in one table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|