| Author |
diffrences between KEY, Index in mysql and postgres
|
Ramina Nibilian
Ranch Hand
Joined: Mar 30, 2005
Posts: 65
|
|
Hi Im not getting what is diffrence between KEY and INDEX in Mysql is there any difference between them ? What is thier correspends in PostgreSQL I mean if i want to port a db from Mysql to postgreSQL then what is replacer of INDEX and KEY Thank you. [ May 19, 2005: Message edited by: Bear Bibeault ]
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26218
|
|
Ramina, A key makes a statement about uniqueness. Databases generally implement a key with a unique index. An index is to improve performance. There are two types of indexes. An index can force uniqueness (like an additional key) or allow duplicates. So a table can have multiple indexes, but only one key.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Ramina Nibilian
Ranch Hand
Joined: Mar 30, 2005
Posts: 65
|
|
Thank you for reply In my case Each table in Mysql have more that one key associated with it in table definition. some tables has Index instead of Key but the indexes are more than one too. but any of tham have just one primary Key , in summry : EAch table has several key and just one "primary Key" or each table has one or more Index , and just one primary key. I want to port this database to PostgreSQL , what is correspond with KEY and INDEX of mysql in postgreSQL Thank you
|
 |
Ramina Nibilian
Ranch Hand
Joined: Mar 30, 2005
Posts: 65
|
|
Hi Pleas some one help me on this I searched in internet and found nothing which could help me
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26218
|
|
Ramina, MySql lets you create a primary key with multiple columns, but not multiple primary keys. Having multiple columns in a primary key means at least one of those must differ in value. So "Female, Jeanne" and "Female, Ramina" would be ok. If the two were both unique keys, "Female" would be a duplicate and be rejected. I avoid the word primary because by definition there can only be one. As far as I know, they map to the same thing in mySql and postgres. These are standard database concepts, so I can't imagine database vendors would implement them differently. (But I haven't actually used postgres.)
|
 |
Masoud Kalali
Author
Ranch Hand
Joined: Jul 08, 2004
Posts: 531
|
|
You can use index declaration for both key and inde of mysql in postgreSQL so any key will become and index in postGRESQL and any index will become an index too. Primary key will be untouched (they are unique Index) hope it helps
|
Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
|
 |
 |
|
|
subject: diffrences between KEY, Index in mysql and postgres
|
|
|