How to list domains

Started by Alexander Cohenabout 22 years ago5 messagesgeneral
Jump to latest
#1Alexander Cohen
alex@toomuchspace.com

How can i get list of all domains available?

thanks!

--
Alexander Cohen
http://www.toomuchspace.com
(819) 348-9237
(819) 432-3443

#2Bruce Momjian
bruce@momjian.us
In reply to: Alexander Cohen (#1)
Re: How to list domains

Alexander Cohen wrote:

How can i get list of all domains available?

Using psql, domains are listed with \dD. They also appear in \dT.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Alexander Cohen
alex@toomuchspace.com
In reply to: Bruce Momjian (#2)
Re: How to list domains

Yes, i just discovered that. Thanks! Actually im trying to display in
an app of mine a list of all types to the user. That goes fine but i
noticed that that list does not have "integer", "double precision" and
simple type names like that. I thought they would be domains. But i
guess they are not. Where can i find these types? What are they?

--
Alexander Cohen
http://www.toomuchspace.com
(819) 348-9237
(819) 432-3443

On Apr 7, 2004, at 2:47 PM, Bruce Momjian wrote:

Show quoted text

Alexander Cohen wrote:

How can i get list of all domains available?

Using psql, domains are listed with \dD. They also appear in \dT.

-- 
Bruce Momjian                        |  http://candle.pha.pa.us
pgman@candle.pha.pa.us               |  (610) 359-1001
+  If your life is a hard drive,     |  13 Roberts Road
+  Christ can be your backup.        |  Newtown Square, Pennsylvania 
19073

---------------------------(end of
broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

#4Bruce Momjian
bruce@momjian.us
In reply to: Alexander Cohen (#3)
Re: How to list domains

Alexander Cohen wrote:

Yes, i just discovered that. Thanks! Actually im trying to display in
an app of mine a list of all types to the user. That goes fine but i
noticed that that list does not have "integer", "double precision" and
simple type names like that. I thought they would be domains. But i
guess they are not. Where can i find these types? What are they?

They are SQL-standard names for our int4, float8 types. They map
internally to those types. I don't know a way to list separately.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#4)
Re: How to list domains

Bruce Momjian <pgman@candle.pha.pa.us> writes:

They are SQL-standard names for our int4, float8 types. They map
internally to those types. I don't know a way to list separately.

You can use format_type() to get the canonical per-spec form. For instance

regression=# select typname, format_type(oid,-1) from pg_type where oid in (1043,23);
typname | format_type
---------+-------------------
varchar | character varying
int4 | integer
(2 rows)

I don't know of any way to get a listing of secondary aliases that the
parser will recognize (such as "int" for int4). They're hardwired into
the grammar rather than being table entries anywhere. Fortunately,
there are not all that many beyond the typname and the format_type forms.

regards, tom lane