Hi
Similar to pg_get_viewdef() and pg_get_functiondef() it would be useful with a pg_get_tabledef() to get a full description of how a table is defined.
Currently the table definition can be extracted with the command:
pg_dump -d foo --schema-only --table=bar | egrep '^[^-]'
The psql command '\d bar' gives some of the same information but it is not in a format where it can be used to create a table.
Extra:
With the pg_get_tabledef() function in place it is very close to be possible to implement pg_dump() within the system. So instead of running:
pg_dump -d foo
one could just run:
psql -d foo -c 'SELECT pg_dump()'
The function could also be called from within a programming language like Java/PHP.
pg_dump has a lot of options where some of them could be parameters to the pg_dump() function. If using a cloud or other webservice this will be an easy way to make an extra backup.