![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I know that I can write one, using the information_schema or pg_catalog information, preferably the latter, and get DDL for tables, indexes and routines as a result. Another popular database variety has a package DBMS_METADATA which contains the function named "GET_DDL", which does precisely what I want. Unfortunately, I got lazy and spoiled by using the other RDBMS systems and would like to know 2 things: 1) Is there a function that will take schema,name and object type as arguments and return the create statement for that object? For indexes, it's trivial, because pg_indexes table contains the create statement for all indexes. Routines can also be easily obtained from the pg_proc which contains arguments, defaults and source. Same goes for the views. All elements are easy to find but creating the function itself would be a bit of work and I don't feel like doing it, if I can use somebody else's work. 2) Is there a ready-made query that will join pg_class, pg_attribute and pg_type to produce effect similar to \d? Anything of that nature that emulates DBA_IND_COLUMNS and DBA_CONS_COLUMNS? I find those two tables very useful and would like having them in my Postgres databases very much. If there is a noble soul who feels like sharing.... |
#3
| |||
| |||
|
|
I guess the closes thing are the pg_get_XXXdef functions() |
#4
| |||
| |||
|
|
On Sun, 13 Jun 2010 12:00:31 +0200, Thomas Kellerer wrote: I guess the closes thing are the pg_get_XXXdef functions() Unfortunately, there exist no function such that XXX = 'table'. Well, I'll make one myself and post the code, that is if anyone is interested. It should be a relatively simple join between pg_class and pg_attribute, if the column type is simple, built-in type. I am not sure how well will it work with the domains. |
![]() |
| Thread Tools | |
| Display Modes | |
| |