views:

66

answers:

1

Hi!

Do you know what happend with pg_get_tabledef function in postgresql 8.4? I'm sure I've been using it with previous versions of postgresql?

I need to get sql 'create table' syntax for existing table in db with indexes, defaults as so on... Maybe they replaced it with something else?

A: 

Take a look at the \dt command at http://www.postgresql.org/docs/8.4/interactive/app-psql.html

You might want to start the terminal with the -E parameter

-E
--echo-hidden
Echo the actual queries generated by \d and other backslash commands. You can use this to study psql's internal operations. This is equivalent to setting the variable ECHO_HIDDEN from within psql.

edit and btw:

http://markmail.org/message/3obwktwfnxfwspxg?q=pg_get_tabledef+type%3Aannouncements:

== PostgreSQL Weekly News - March 31 2007 ==
[...}
Bruce Momjian committed:
[...]
- Remove TODO due to lack of interest: "Add pg_get_acldef(), pg_get_typedefault(), pg_get_attrdef(), pg_get_tabledef(), pg_get_domaindef(), pg_get_functiondef()."
VolkerK
I want to do it from source code of my program. For functions there is pg_get_functiondef, for views pg_get_viewdef and I can't fund anything for tables...
Adrian Serafin
VolkerK
not copy when i retrieve the schema and execute it on different db
Adrian Serafin
It will show you the sql query to get the information you need. Copy the query, not the result.
VolkerK