| От | Tom Lane |
|---|---|
| Тема | Re: How to get the name of a table's primary key? |
| Дата | |
| Msg-id | 15377.1016312315@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: How to get the name of a table's primary key? (Christian von Kietzell <chris@gammu.ath.cx>) |
| Список | pgsql-general |
Christian von Kietzell <chris@gammu.ath.cx> writes: > Suppose, I've got the table shown above. I've only got its name. What > I want is the column name the primary key is created on. How can I do > that? Basically, which of foo_pkey and foo_data is the primary key? You poke around in the system catalogs. Look in pg_index for a row that describes an index on your table (join indrelid to pg_class.oid) and has indisprimary true. (If no such row, there's no primary key.) Then look in pg_attribute to get the column name(s) based on the column numbers you see in indkey. See http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/catalog-pg-index.html regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера