Is there an efficient way to check whether a particular index or constraint exists?

Поиск
Список
Период
Сортировка
От jonathan.lister@vaisala.com
Тема Is there an efficient way to check whether a particular index or constraint exists?
Дата
Msg-id D3081BDF8E6A5D40A4E82155E83C865E132525@birdx1.corp.vaisala.com
обсуждение исходный текст
Ответы Re: Is there an efficient way to check whether a particular  ("Ben K." <bkim@coe.tamu.edu>)
Список pgsql-admin
An application includes code that optionally does some admin tasks. Rather than just try to create objects, it's presumably better to test if they exist before attempting to create them.
So far I can check
 
if a function exists with:
      ps = dbConn.prepareStatement("select count(routine_name) from information_schema.routines"
        + " where routine_catalog = ?
        + " and routine_name = ?");   
if a table exists with:
      ps = dbConn.prepareStatement("select count(*) from pg_tables where tablename = ?"); // and schemaname = ? and tableowner = ?");
if a column in a table exists with:
      ps = dbConn.prepareStatement("select count(a.attname)"
        + " from pg_user u, pg_type t, pg_attribute a, pg_type n "
        + " where u.usesysid = t.typowner "
        + " and t.typrelid = a.attrelid and t.typtype = 'c' and not (t.typname ~* 'pg_') "
        + " and n.typelem = a.atttypid "
        + " and substr(n.typname, 1, 1) = '_' "
        + " and a.attnum > 0 "
        + " and t.typname = ?"
        + " and a.attname = ?");
 
Are there equivalent ways to check for indeces and constraints?
 

В списке pgsql-admin по дате отправления:

Предыдущее
От: Szabolcs BALLA
Дата:
Сообщение: Autovacuum probably not working?
Следующее
От: Szabolcs BALLA
Дата:
Сообщение: Re: Autovacuum probably not working?