Re: Check for table existence

Поиск
Список
Период
Сортировка
От Haller Christoph
Тема Re: Check for table existence
Дата
Msg-id 200111291458.PAA05990@rodos
обсуждение исходный текст
Ответ на Check for table existence  (Michael Knudsen <mk267673@but.auc.dk>)
Список pgsql-sql
Hi Michael, 
> 
> 
>     1. How can I check if a given table exists?
>     2. How can I check if a given existing table has the right layout? (Correct
> column names and types)
> 
Try this 
create view my_tbldescription as 
select 
u.usename, t.typname AS tblname, 
a.attname, a.atttypid, n.typname AS atttypname, 
int4larger(a.attlen, a.atttypmod - 4) AS atttyplen, 
a.attnotnull, a.attnum 
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 ;

select * from my_tbldescription order by 1,2,8 ;

It should tell you all you want to know. 
Regards, Christoph 


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

Предыдущее
От: Markus Bertheau
Дата:
Сообщение: Re: Fixing faulty dates - select on day part of a date field
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: PL/pgSQL loops?