Re: Finding the primary key of tables
От | George Silva |
---|---|
Тема | Re: Finding the primary key of tables |
Дата | |
Msg-id | AANLkTikEG5ucZPpCZvZdhNE84eUQJOaKHWq-i3k_uyHU@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Finding the primary key of tables (Merlin Moncure <mmoncure@gmail.com>) |
Список | pgsql-general |
Thanks a million. Rusty SQL :P
--
George R. C. Silva
Desenvolvimento em GIS
http://blog.geoprocessamento.net
2010/8/3 Merlin Moncure <mmoncure@gmail.com>
2010/8/3 George Silva <georger.silva@gmail.com>:> I'm going for Merlin's solution. Its the easiest one :Pyup -- you are supposed be matching on constraint_name, not just
>
> But I'm also having a problem:
>
> SELECT column_name FROM information_schema.key_column_usage k
> LEFT OUTER JOIN information_schema.table_constraints ON (k.table_name =
> table_constraints.table_name)
> WHERE
> table_constraints.constraint_type = 'PRIMARY KEY'
> AND k.table_name = 'acidentes'
> AND k.table_schema = 'public'
>
> this still returns me multiple columns. Did I forgot something?
table_name. try:SELECT column_name FROM information_schema.key_column_usage kLEFT OUTER JOIN information_schema.table_constraints USING
(table_schema, table_name, constraint_name)merlinWHERE
table_constraints.constraint_type = 'PRIMARY KEY'
AND k.table_name = 'acidentes'
AND k.table_schema = 'public'
--
George R. C. Silva
Desenvolvimento em GIS
http://blog.geoprocessamento.net
В списке pgsql-general по дате отправления: