List:General Discussion« Previous MessageNext Message »
From:Steve Edberg Date:June 23 2007 2:21pm
Subject:Re: duplicate key question
View as plain text  
At 10:19 PM -0500 6/22/07, Chris W wrote:
>when you get a duplicate key error it says something to the effect 
>of "Duplicate entry 'xyz' for key x"
>What I want to know is how to find out what table fields are part of key x?


'show index' is what you want, I think:

http://dev.mysql.com/doc/refman/5.0/en/show-index.html

Example:

mysql-5.0.15-log@localhost> create table test (c1 int, c2 int, index 
i1 (c1,c2));
Query OK, 0 rows affected (0.02 sec)

mysql-5.0.15-log@localhost> show index from test\G
*************************** 1. row ***************************
        Table: test
   Non_unique: 1
     Key_name: i1
Seq_in_index: 1
  Column_name: c1
    Collation: A
  Cardinality: NULL
     Sub_part: NULL
       Packed: NULL
         Null: YES
   Index_type: BTREE
      Comment:
*************************** 2. row ***************************
        Table: test
   Non_unique: 1
     Key_name: i1
Seq_in_index: 2
  Column_name: c2
    Collation: A
  Cardinality: NULL
     Sub_part: NULL
       Packed: NULL
         Null: YES
   Index_type: BTREE
      Comment:
2 rows in set (0.00 sec)

	steve


>--
>Chris W
>KE5GIX
>
>"Protect your digital freedom and privacy, eliminate DRM, learn more 
>at http://www.defectivebydesign.org/what_is_drm"
>
>Gift Giving Made Easy
>Get the gifts you want & give the gifts they want
>One stop wish list for any gift, from anywhere, for any occasion!
>http://thewishzone.com


-- 
+--------------- my people are the people of the dessert, ---------------+
| Steve Edberg                                http://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center                            sbedberg@stripped |
| Bioinformatics programming/database/sysadmin             (530)754-9127 |
+---------------- said t e lawrence, picking up his fork ----------------+
Thread
duplicate key questionChris W23 Jun
  • Re: duplicate key questionmos23 Jun
    • Re: duplicate key questionChris W23 Jun
  • Re: duplicate key questionSteve Edberg23 Jun