Re: Primary Keys

Поиск
Список
Период
Сортировка
Искать
От
Melvin Davidson
Тема
Re: Primary Keys
Дата
Msg-id
CANu8FiyQsQg7bF3FPT+FU=kK=WJHfewPp+6qE9fxF6YXr+WNCA@mail.gmail.com
Ответ на
Primary Keys (Dustin Kempter)
Список
Дерево обсуждения
Clarify "allow_system_table_mods" Melvin Davidson <melvin6925@gmail.com>
Re: Clarify "allow_system_table_mods" Adrian Klaver <adrian.klaver@aklaver.com>
Re: Clarify "allow_system_table_mods" Adrian Klaver <adrian.klaver@aklaver.com>
Re: Clarify "allow_system_table_mods" Melvin Davidson <melvin6925@gmail.com>
Re: Clarify "allow_system_table_mods" Melvin Davidson <melvin6925@gmail.com>
Re: Clarify "allow_system_table_mods" "David G. Johnston" <david.g.johnston@gmail.com>
Re: Clarify "allow_system_table_mods" Stephen Frost <sfrost@snowman.net>
Re: Clarify "allow_system_table_mods" Melvin Davidson <melvin6925@gmail.com>
Re: Clarify "allow_system_table_mods" Stephen Frost <sfrost@snowman.net>
Re: Clarify "allow_system_table_mods" Melvin Davidson <melvin6925@gmail.com>
Re: Clarify "allow_system_table_mods" Stephen Frost <sfrost@snowman.net>
Re: Clarify "allow_system_table_mods" "David G. Johnston" <david.g.johnston@gmail.com>
Re: Clarify "allow_system_table_mods" Melvin Davidson <melvin6925@gmail.com>
Re: Clarify "allow_system_table_mods" Stephen Frost <sfrost@snowman.net>
Re: Clarify "allow_system_table_mods" Adrian Klaver <adrian.klaver@aklaver.com>
Re: Clarify "allow_system_table_mods" Tom Lane <tgl@sss.pgh.pa.us>
Re: Clarify "allow_system_table_mods" Melvin Davidson <melvin6925@gmail.com>
Re: Clarify "allow_system_table_mods" "David G. Johnston" <david.g.johnston@gmail.com>
Primary Keys Dustin Kempter <dustink@consistentstate.com>
Re: Primary Keys Adrian Klaver <adrian.klaver@aklaver.com>
Re: Primary Keys Melvin Davidson <melvin6925@gmail.com>
Re: Primary Keys John McKown <john.archie.mckown@gmail.com>
Re: Clarify "allow_system_table_mods" Tom Lane <tgl@sss.pgh.pa.us>
Re: Clarify "allow_system_table_mods" Melvin Davidson <melvin6925@gmail.com>


On Fri, Apr 29, 2016 at 2:07 PM, Dustin Kempter <dustink@consistentstate.com> wrote:
Hi all,
Is there a query I can run that will scan through all the tables of a database and give me a list of all tables without a primary key? Im not having any luck with this.

Thanks in advance!


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Please, ALWAYS provide Postgresql version & O/S, regardless of whether you think it is pertinet.


Now try this:

SELECT n.nspname, c.relname as table
  FROM pg_class c
    JOIN pg_namespace n ON (n.oid =c.relnamespace )
 WHERE relkind = 'r' AND
       relname NOT LIKE 'pg_%' AND
       relname NOT LIKE 'sql_%' AND
       relhaspkey = FALSE
ORDER BY n.nspname, c.relname;

--
Melvin Davidson
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.
В списке pgsql-general по дате отправления
От: John R Pierce
Дата:
От: John McKown
Дата:
Сообщение: Re: Primary Keys
FAQ