DevHeads.net

psql - TYPE DEFINITION

Hello

I tired \dT and dT+  to see the type related information but I am interested about the definition ,  Is there a way to see the type definition in psql   

Regards

Comments

Re: psql - TYPE DEFINITION

By Adrian Klaver at 01/16/2012 - 10:52

On Monday, January 16, 2012 6:38:49 am salah jubeh wrote:

\dTS+

Does the above get you the information you need?

Re: psql - TYPE DEFINITION

By salah jubeh at 01/16/2012 - 13:44

Hello Adrian

when I run \dTS+ I get the same result as  \dT+

                            ^
testdb=# create type test AS (a int , b int);
CREATE TYPE
testdb=# \dT+ test
                 List of data types
 Schema | Name | Internal name | Size  | Description
--------+------+---------------+-------+-------------
 public | test | test          | tuple |
(1 row)

testdb=# \dTS+ test
                 List of data types
 Schema | Name | Internal name | Size  | Description
--------+------+---------------+-------+-------------
 public | test | test          | tuple |
(1 row)

Regards

 

On Monday, January 16, 2012 6:38:49 am salah jubeh wrote:

\dTS+

Does the above get you the information you need?

Re: psql - TYPE DEFINITION

By Adrian Klaver at 01/16/2012 - 16:34

On 01/16/2012 09:44 AM, salah jubeh wrote:
So you want to get information from a user created type.
So you have two options:
1) Add a comment to the type:
COMMENT ON TYPE test is 'create type test AS (a int , b int)';

test=> \dT
List of data types
Schema | Name | Description
--------+---------+-------------------------------------
public | ghstore |
public | hstore |
public | test | create type test AS (a int , b int)

2) Get the information from the pg_type system catalog.

test=> SELECT * from pg_type where typname='test';

I am not showing the output because it does not display well.

For more information on what is being returned take a look at:

<a href="http://www.postgresql.org/docs/9.0/interactive/catalog-pg-type.html" title="http://www.postgresql.org/docs/9.0/interactive/catalog-pg-type.html">http://www.postgresql.org/docs/9.0/interactive/catalog-pg-type.html</a>