pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedTable definition
7+ messages / 4 participants
[nested] [flat]
* Table definition
@ 2004-11-16 14:04 Bruno Prévost <bp@interaction.ws>
2004-11-16 15:16 ` Re: Table definition Peter Eisentraut <peter_e@gmx.net>
2004-11-16 15:29 ` Re: Table definition Sam Mason <sam@samason.me.uk>
0 siblings, 2 replies; 7+ messages in thread
From: Bruno Prévost @ 2004-11-16 14:04 UTC (permalink / raw)
To: pgsql-sql
Les consultants Interaction | stationery
Hi,
Anybody know how to obtain the table definition in text.
Something like "select definition from pg_catalog.pg_views where viewname = 'xxx'" but for a table.
Thanks
Bruno
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Table definition
2004-11-16 14:04 Table definition Bruno Prévost <bp@interaction.ws>
@ 2004-11-16 15:16 ` Peter Eisentraut <peter_e@gmx.net>
2004-11-16 15:40 ` Re: Table definition Bruno Prévost <bp@interaction.ws>
1 sibling, 1 reply; 7+ messages in thread
From: Peter Eisentraut @ 2004-11-16 15:16 UTC (permalink / raw)
To: Bruno Prévost <bp@interaction.ws>; +Cc: pgsql-sql
Am Dienstag, 16. November 2004 15:04 schrieb Bruno Prévost:
> Anybody know how to obtain the table definition in text.
Use pg_dump.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Table definition
2004-11-16 14:04 Table definition Bruno Prévost <bp@interaction.ws>
2004-11-16 15:16 ` Re: Table definition Peter Eisentraut <peter_e@gmx.net>
@ 2004-11-16 15:40 ` Bruno Prévost <bp@interaction.ws>
2004-11-16 16:13 ` Re: Table definition Peter Eisentraut <peter_e@gmx.net>
0 siblings, 1 reply; 7+ messages in thread
From: Bruno Prévost @ 2004-11-16 15:40 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; +Cc: pgsql-sql
I need to use it in sql.
Thk
Bruno
----- Original Message -----
From: "Peter Eisentraut" <peter_e@gmx.net>
To: "Bruno Prévost" <bp@interaction.ws>
Cc: <pgsql-sql@postgresql.org>
Sent: Tuesday, November 16, 2004 10:16 AM
Subject: Re: [SQL] Table definition
> Am Dienstag, 16. November 2004 15:04 schrieb Bruno Prévost:
>> Anybody know how to obtain the table definition in text.
>
> Use pg_dump.
>
> --
> Peter Eisentraut
> http://developer.postgresql.org/~petere/
>
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Table definition
2004-11-16 14:04 Table definition Bruno Prévost <bp@interaction.ws>
2004-11-16 15:16 ` Re: Table definition Peter Eisentraut <peter_e@gmx.net>
2004-11-16 15:40 ` Re: Table definition Bruno Prévost <bp@interaction.ws>
@ 2004-11-16 16:13 ` Peter Eisentraut <peter_e@gmx.net>
2004-11-16 16:49 ` Re: Table definition Bruno Prévost <bp@interaction.ws>
0 siblings, 1 reply; 7+ messages in thread
From: Peter Eisentraut @ 2004-11-16 16:13 UTC (permalink / raw)
To: Bruno Prévost <bp@interaction.ws>; +Cc: pgsql-sql
Am Dienstag, 16. November 2004 16:40 schrieb Bruno Prévost:
> I need to use it in sql.
There is no direct way to do this in SQL, but I can offer you the following
alternative:
CREATE FUNCTION get_table_definition(text) RETURNS text AS '
#!/bin/sh
pg_dump -t $1
' LANGUAGE plsh;
:)
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Table definition
2004-11-16 14:04 Table definition Bruno Prévost <bp@interaction.ws>
2004-11-16 15:16 ` Re: Table definition Peter Eisentraut <peter_e@gmx.net>
2004-11-16 15:40 ` Re: Table definition Bruno Prévost <bp@interaction.ws>
2004-11-16 16:13 ` Re: Table definition Peter Eisentraut <peter_e@gmx.net>
@ 2004-11-16 16:49 ` Bruno Prévost <bp@interaction.ws>
0 siblings, 0 replies; 7+ messages in thread
From: Bruno Prévost @ 2004-11-16 16:49 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; +Cc: pgsql-sql
It could help me, but pg_dump give all foreigns key and index creation.
I'm not sure if it's not better to write a custom function in plpgsql.
Bruno
----- Original Message -----
From: "Peter Eisentraut" <peter_e@gmx.net>
To: "Bruno Prévost" <bp@interaction.ws>
Cc: <pgsql-sql@postgresql.org>
Sent: Tuesday, November 16, 2004 11:13 AM
Subject: Re: [SQL] Table definition
> Am Dienstag, 16. November 2004 16:40 schrieb Bruno Prévost:
>> I need to use it in sql.
>
> There is no direct way to do this in SQL, but I can offer you the
> following
> alternative:
>
> CREATE FUNCTION get_table_definition(text) RETURNS text AS '
> #!/bin/sh
> pg_dump -t $1
> ' LANGUAGE plsh;
>
> :)
>
> --
> Peter Eisentraut
> http://developer.postgresql.org/~petere/
>
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Table definition
2004-11-16 14:04 Table definition Bruno Prévost <bp@interaction.ws>
@ 2004-11-16 15:29 ` Sam Mason <sam@samason.me.uk>
1 sibling, 0 replies; 7+ messages in thread
From: Sam Mason @ 2004-11-16 15:29 UTC (permalink / raw)
To: pgsql-sql
Bruno Prévost wrote:
>Anybody know how to obtain the table definition in text.
Not quite sure if this is quite what you're after, but would:
$ pg_dump -st foo
help at all? It gives out the SQL that you would need to enter to
re-create the table.
Sam
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Table definition
@ 2004-11-16 15:07 Goutam Paruchuri <gparuchuri@oneil.com>
0 siblings, 0 replies; 7+ messages in thread
From: Goutam Paruchuri @ 2004-11-16 15:07 UTC (permalink / raw)
To: Bruno Prévost <bp@interaction.ws>; pgsql-sql
Probably there is no direct way get the definition (i could not find one atleast).
You can probably write a custom function which gives all columns, indexes and formulate a create table statement (text definition).
Let us know if you find a way out.
- Goutam
________________________________
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Bruno Prévost
Sent: Tuesday, November 16, 2004 9:04 AM
To: pgsql-sql@postgresql.org
Subject: [SQL] Table definition
Hi,
Anybody know how to obtain the table definition in text.
Something like "select definition from pg_catalog.pg_views where viewname = 'xxx'" but for a table.
Thanks
Bruno
Confidentiality Notice
The information contained in this e-mail is confidential and intended for use only by the person(s) or organization listed in the address. If you have received this communication in error, please contact the sender at O'Neil & Associates, Inc., immediately. Any copying, dissemination, or distribution of this communication, other than by the intended recipient, is strictly prohibited.
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2004-11-16 16:49 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-11-16 14:04 Table definition Bruno Prévost <bp@interaction.ws>
2004-11-16 15:16 ` Peter Eisentraut <peter_e@gmx.net>
2004-11-16 15:40 ` Bruno Prévost <bp@interaction.ws>
2004-11-16 16:13 ` Peter Eisentraut <peter_e@gmx.net>
2004-11-16 16:49 ` Bruno Prévost <bp@interaction.ws>
2004-11-16 15:29 ` Sam Mason <sam@samason.me.uk>
2004-11-16 15:07 Re: Table definition Goutam Paruchuri <gparuchuri@oneil.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox