Re: Retrieving column names and table names of a database

Поиск
Список
Период
Сортировка
От nourry@ensinfo.univ-nantes.fr (Frederic Nourry)
Тема Re: Retrieving column names and table names of a database
Дата
Msg-id 199905181252.OAA03376@dec1.ensinfo.univ-nantes.fr
обсуждение исходный текст
Ответ на Retrieving column names and table names of a database  ("Matthias Seiferth" <matthias.seiferth@ipk.fhg.de>)
Список pgsql-sql
>Hi,
>, this may sound stupid, but is there a way of retrieving the table names and >column names of a database using SQL. I
knowthere
 
>is \d in psql, but I don´t know if there is something similar in SQL or if there >is a function I can call. 
>Please reply even if there is no function
>
>Thanks in advance for your help
>
>Matthias
>. 
To retrieve the table names , use the pg_tables :   SELECT tablename FROM pg_tables WHERE tablename NOT LIKE 'pg_%';
To retrieve the column names , you can use the pg_attribute and
pg_type tables :    SELECT attname , typname FROM pg_attribute , pg_type WHERE    typrelid=attrelid AND typname =
'banals';    if your table name is 'banals' , but this will give you 6 columns that
 
you haven't declared : cmax,xmax,cmin,xmin,oid,ctid .
 If you want column names with its type :     SELECT attname , opcname , atttypmod FROM pg_attribute,pg_type,
pg_opclassWHERE attrelid=typrelid AND atttypid=opcdeftype AND    typname = 'banals' ;         if your table name is
'banals', but this will give the
 
column 'oid' you haven't declared
 You can find all tables names in <where you put psql>//data/base/ .
Sorry for my english !


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

Предыдущее
От: Heiko Wilms
Дата:
Сообщение: querying arrays
Следующее
От: Ana Roizen
Дата:
Сообщение: Updating and null values.