Re: [SQL] how can tell if a column is a primary key?
От | Tom Lane |
---|---|
Тема | Re: [SQL] how can tell if a column is a primary key? |
Дата | |
Msg-id | 18416.942679456@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: [SQL] how can tell if a column is a primary key? ("D'Arcy" "J.M." Cain <darcy@druid.net>) |
Ответы |
Re: [SQL] how can tell if a column is a primary key?
|
Список | pgsql-sql |
"D'Arcy" "J.M." Cain <darcy@druid.net> writes: > Here's another FAQ but one that no one has ever answered that I know of. > How do I generalize the above query so that it returns information on > all the elements of complex keys? indkey and indclass are type int28 and oid8 respectively, which are almost like 8-element arrays, except that for historical reasons they index from 0 not 1. So instead of pg_index.indkey[0] = pg_attribute.attnum write pg_index.indkey[1] = pg_attribute.attnum to find attributes that are secondary index columns, [2] for tertiary, etc. Unused positions in indkey[] are filled with zeroes. If you have code on the client side it'd probably make most sense just to pull back the whole value of indkey[] and then issue separate SELECTs to find out what the referenced attributes are, instead of probing 8 times to see if you get anything... BTW, if indproc is nonzero then you are looking at a functional index, and in that case the indkey[] array describes the arguments to the function; there is only one index column, namely the function result. regards, tom lane
В списке pgsql-sql по дате отправления: