views:

25

answers:

1

HI, this might sound like a silly question but.. i've created several "types" in a database using the CREATE TYPE command, now i'd like to use the same types in a different database in a different server and i didn't save my CREATE TYPE statements. Is there a way to export the types?? or even display the list of types with their fields and fieldtypes??

+1  A: 

This is what pgAdmin3 uses:

SELECT   t.oid                                   ,
         t.*                                     ,
         format_type(t.oid, NULL)    AS ALIAS    ,
         pg_get_userbyid(t.typowner) AS typeowner,
         e.typname                   AS element  ,
         description                             ,
         ct.oid AS taboid
FROM     pg_type T
         LEFT OUTER JOIN pg_type E          ON e.oid     =t.typelem
         LEFT OUTER JOIN pg_class ct        ON ct.oid    =t.typrelid AND      ct.relkind <> 'c'
         LEFT OUTER JOIN pg_description des ON des.objoid=t.oid
WHERE    t.typtype                                      != 'd'
AND      t.typname                                NOT LIKE E'\\_%'
AND      t.typnamespace                                  = 3278632::oid
AND      ct.oid                                    IS NULL
ORDER BY t.typname
Frank Heikens
=) thxs a lot, i had to change the typenamespace in the query and remove the last "AND" statement. Now i'll have to find out how to export my Types into a new DB
pleasedontbelong
well, finally i found the CREATE TYPE statement in the dump. In the phppgadmin i used the export tool =) thanks again
pleasedontbelong