| От | Orion Henry |
|---|---|
| Тема | primary keys |
| Дата | |
| Msg-id | 4446F471.1090503@orangekids.org обсуждение исходный текст |
| Ответы |
Re: primary keys
|
| Список | pgsql-general |
I'm trying to craft a query that will determine what column(s) are the primary key for a given table. I have succeeded but the query is so ugly that it borders on silly and cannot work for an arbitrary number of tables since indkey is an int2vect and the ANY keyword does not work on it. Please tell me there's an easier way to do this. Here is the query for tablename $table. SELECT attname FROM pg_index JOIN pg_class ON (indrelid = pg_class.oid) JOIN pg_attribute ON (attrelid = pg_class.oid) WHERE indisprimary IS TRUE AND (attnum = indkey[0] OR attnum = indkey[1] OR attnum = indkey[2]) AND relname = '$table'; Orion
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера