Skip site navigation (1) Skip section navigation (2)

Re: No way to list DDL for a new type

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>
Cc: "Rajesh Chopra" <rc_bio(at)yahoo(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: No way to list DDL for a new type
Date: 2008-06-11 13:57:03
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
On 6/11/08, Heikki Linnakangas <heikki(at)enterprisedb(dot)com> wrote:
> Rajesh Chopra wrote:
> > Hi,
> > I created a new type as follows:
> > CREATE TYPE compfoo AS (f1 int, f2 text);
> >
> > Now I need the DDL which postgres used to create this type.
> >
> Huh, what do you mean? That CREATE TYPE statement is DDL.

I think what the OP was asking was how to reverse engineer the DDL out
of the database for an already created type (but you're right, this is
not a bug).  in psql, the create type source sql is not displayed like
it is for views for example.

There are a couple of ways to do this:
*) pg_dump -s and examine the output
*) fire up pgadmin, browse types folder-- pgadmin shows source ddl for
all database objects

Also, composite types (CREATE TYPE AS), are trivially reverse
engineered from the column lists.  Non composite types are a little
more complicated.

side thought -- it would be nice for pg_restore to be able to extract
more specific objects out of the custom format dump than what it
currently allows...types for example.


In response to

pgsql-bugs by date

Next:From: Pierre Le MouëllicDate: 2008-06-11 14:48:20
Subject: Bug in select to_char(now(), 'YYYY/MM/DD HH24:MI:SS:MS')
Previous:From: Heikki LinnakangasDate: 2008-06-11 07:28:12
Subject: Re: No way to list DDL for a new type

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group