12

I'm using mysql workbench and under the object information section the column names and types are listed. It it shows what column has the primary key (if there is one.)

However it doesn't list the unique indexes/keys.

Is there any way I can view which columns have unique indexes/keys on them?

3 Answers 3

20

I don't think there is a special interface for that... you can still use the direct query:

show indexes from <table>

That's wrong, it exists! Check Hexparrot answer.

To see it, right click on you table -> alter table, and you'll find the "indexes" tables

0
18

You're looking for the indexes tab: "The Indexes tab holds all index information for your table. Use this tab to add, drop, and modify indexes."

http://dev.mysql.com/doc/workbench/en/wb-table-editor.html#wb-table-editor-indexes-tab

2
  • In 5.2 they've renamed it the "Indices" tab, but it's the same stuff. Commented Jul 27, 2013 at 19:08
  • 1
    In short: right click the table -> ALTER TABLE. Then at the bottom you have some tabs, including 'Indexes' ...
    – phil_w
    Commented Oct 9, 2013 at 12:55
2

This approach may seems convoluted but you can see the table as a CREATE TABLE statement as follows (for this example the table you are looking up is mydb.mytable):

Step 01 : Open the MySQL Workbench

Step 02 : Open SQL Editor

Step 03 : In the left pane, right-click mydb and Click Set as Default Schema

Step 04 : In the above Query Pane called Query 1 type SHOW CREATE TABLE mytable;

Step 05 : On the toolbar, click the fifth icon (Execute SQL Script in Connected Server)

Step 06 : In Query 1 Result below, float the mouse over the CREATE TABLE output (popup window with the table design will appear for 5-10 sec)

Step 07 : In Query 1 Result below, float the mouse over the CREATE TABLE output. Right-click. Menu appears. Choose Open Value in Viewer

Step 08 : Popup window with title Edit Data for Create Table

Step 09 : Click Text tab

Give it a Try !!!

CAVEAT You can use SHOW INDEXES FROM mytable; but the output is in rows which you have to carefully read. The CREATE TABLE approach just gives a cleaner display.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.