Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

describe phoenix table to find primary key

avatar
Master Guru

I created a phoenix table with 100 columns. I forgot what the primary key for the table. The primary key was build with at least 5 to 6 columns, can't say for sure. Any easy way to have phoenix tell me what the primary key is on a table?

4 REPLIES 4

avatar
Expert Contributor

The `SYSTEM.CATLOG` table contains a column called `KEY_SEQ`. If this contains an integer, it's a key column. E.g.

SELECT column_name FROM system.catalog WHERE table_name = '{{ your table name }}' AND key_seq IS NOT NULL;

avatar
Cloudera Employee

You can try :

0: jdbc:phoenix:> !primarykeys $TABLE_NAME
+------------+--------------+-------------+------------------------+----------+----------+--------------+------------+------------+-+
| TABLE_CAT  | TABLE_SCHEM  | TABLE_NAME  |      COLUMN_NAME       | KEY_SEQ  | PK_NAME  | ASC_OR_DESC  | DATA_TYPE  | TYPE_NAME  | |
+------------+--------------+-------------+------------------------+----------+----------+--------------+------------+------------+-+
|            | $SCHEMA      | $TABLE      | col1                   | 1        | PK       | A            | 12         | VARCHAR    | |
|            | $SCHEMA      | $TABLE      | col2                   | 2        | PK       | A            | 12         | VARCHAR    | |
+------------+--------------+-------------+------------------------+----------+----------+--------------+------------+------------+-+

avatar
Explorer

This doesn't work 

avatar
Community Manager

@Sunny93 as this is an older post, you would have a better chance of receiving a resolution by starting a new thread. This will also be an opportunity to provide details specific to your environment that could aid others in assisting you with a more accurate answer to your question. You can link this thread as a reference in your new post.



Regards,

Vidya Sargur,
Community Manager


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community: