Table definition
This is a multi-part message in MIME format.
------=_NextPart_000_02A9_01C4CBBB.4611EFC0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
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 =3D 'xxx'" but for a table.
Thanks
Bruno
------=_NextPart_000_02A9_01C4CBBB.4611EFC0
Content-Type: text/html;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Les consultants Interaction | stationery</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dutf-8"><BASE
href=3D"file://C:\Documents and Settings\bruno.INTERACTION\Application =
Data\Microsoft\Stationery\">
<META content=3D"MSHTML 6.00.2900.2523" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV> </DIV>
<DIV>Hi,</DIV>
<DIV>Anybody know how to obtain the table definition in text.</DIV>
<DIV>Something like "select definition from pg_catalog.pg_views where =
viewname =3D
'xxx'" but for a table.</DIV>
<DIV>Thanks</DIV>
<DIV>Bruno</DIV>
<DIV> </DIV></BODY></HTML>
------=_NextPart_000_02A9_01C4CBBB.4611EFC0--
Re: Table definition
This is a multi-part message in MIME format.
------_=_NextPart_001_01C4CBED.F8C958B5
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Probably there is no direct way get the definition (i could not find one at=
least).
You can probably write a custom function which gives all columns, indexes a=
nd formulate a create table statement (text definition).
Let us know if you find a way out.
- Goutam
________________________________
From: pgsql-sql-owner [at] postgresql.org [mailto:pgsql-sql-owner [at] postgresql.or=
g] On Behalf Of Bruno Pr=E9vost
Sent: Tuesday, November 16, 2004 9:04 AM
To: pgsql-sql [at] postgresql.org
Subject: [SQL] Table definition
=09
=09
Hi,
Anybody know how to obtain the table definition in text.
Something like "select definition from pg_catalog.pg_views where viewname =
=3D 'xxx'" but for a table.
Thanks
Bruno
Confidentiality Notice
The information contained in this e-mail is confidential and intended for u=
se 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 distributio=
n of this communication, other than by the intended recipient, is strictly =
prohibited.
------_=_NextPart_001_01C4CBED.F8C958B5
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Les consultants Interaction | stationery</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Diso-8859-1"=
><BASE
href=3D"file://C:\Documents and Settings\bruno.INTERACTION\Application Data=
\Microsoft\Stationery\">
<META content=3D"MSHTML 6.00.2800.1458" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D267470515-16112004><FONT face=3DA=
rial
color=3D#0000ff size=3D2>Probably there is no direct way get the definition=
(i could
not find one atleast).</FONT></SPAN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D267470515-16112004><FONT face=3DA=
rial
color=3D#0000ff size=3D2>You can probably write a custom function which giv=
es all
columns, indexes and formulate a create table statement (text
definition).</FONT></SPAN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D267470515-16112004><FONT face=3DA=
rial
color=3D#0000ff size=3D2></FONT></SPAN> </DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D267470515-16112004><FONT face=3DA=
rial
color=3D#0000ff size=3D2>Let us know if you find a way out.</FONT></SP=
AN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D267470515-16112004><FONT face=3DA=
rial
color=3D#0000ff size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D267470515-16112004></SPAN><FONT face=3DArial><FONT
color=3D#0000ff><FONT size=3D2>- Goutam</FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT color=3D#0000ff><FONT size=3D2><SPAN
class=3D267470515-16112004></SPAN></FONT></FONT></FONT><BR> </DIV>
<BLOCKQUOTE dir=3Dltr
style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px soli=
d; MARGIN-RIGHT: 0px">
<DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr align=3Dleft>
<HR tabIndex=3D-1>
<FONT face=3DTahoma size=3D2><B>From:</B> pgsql-sql-owner [at] postgresql.org=
[mailto:pgsql-sql-owner [at] postgresql.org] <B>On Behalf Of </B>Bruno
Pr=E9vost<BR><B>Sent:</B> Tuesday, November 16, 2004 9:04 AM<BR><B>To:</B=
>
pgsql-sql [at] postgresql.org<BR><B>Subject:</B> [SQL] Table
definition<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV> </DIV>
<DIV>Hi,</DIV>
<DIV>Anybody know how to obtain the table definition in text.</DIV>
<DIV>Something like "select definition from pg_catalog.pg_views where vie=
wname
=3D 'xxx'" but for a table.</DIV>
<DIV>Thanks</DIV>
<DIV>Bruno</DIV>
<DIV> </DIV></BLOCKQUOTE><FONT SIZE=3D3><BR>
<BR>
Confidentiality Notice<BR>
The information contained in this e-mail is confidential and intended for u=
se 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 distributio=
n of this communication, other than by the intended recipient, is strictly =
prohibited.<BR>
</FONT>
</BODY></HTML>
------_=_NextPart_001_01C4CBED.F8C958B5--
Re: 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/
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
Re: Table definition
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
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
Re: Table definition
I need to use it in sql.
Thk
Bruno
----- Original Message -----
From: "Peter Eisentraut" <peter_e [at] gmx.net>
To: "Bruno Prévost" <bp [at] interaction.ws>
Cc: <pgsql-sql [at] 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/
>
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo [at] postgresql.org)
Re: 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/
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
Re: Table definition
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 [at] gmx.net>
To: "Bruno Prévost" <bp [at] interaction.ws>
Cc: <pgsql-sql [at] 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/
>
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo [at] postgresql.org)