Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL: find information about user defined types

Where is information about user-defined types stored?

Are there some tables which contain information about the fields of a user-defined composite type, their names, etc.?

like image 624
Antonio F. Avatar asked Aug 08 '11 08:08

Antonio F.


People also ask

How do I find Postgres database details?

Use \l or \l+ in psql to show all databases in the current PostgreSQL server. Use the SELECT statement to query data from the pg_database to get all databases.

What is user-defined data type in PostgreSQL?

The PostgreSQL user-defined data type is used to generate user-defined data types with the help of Create DOMAIN and CREATE TYPE. The CREATE DOMAIN command is used to generate a user-defined data type with constraints such as CHECK, NOT NULL, etc.

How do I find special characters in PostgreSQL?

SELECT * FROM spatial_ref_sys WHERE srtext LIKE '%\ /%'; Sometimes these ticks are very useful for searching special characters in a database.


2 Answers

The catalog pg_type stores information about data types. Base types and enum types (scalar types) are created with CREATE TYPE, and domains with CREATE DOMAIN.

More information about pg_type plz visit http://www.postgresql.org/docs/9.0/static/catalog-pg-type.html

like image 95
francs Avatar answered Oct 04 '22 14:10

francs


Information about the fields constituting a composite type can be retrieved like this:

select * from pg_attribute where attrelid =
  (select typrelid from pg_type where typname = 't_employee')

where t_employee would be the name of the composite type.

like image 33
oberstet Avatar answered Oct 04 '22 15:10

oberstet