Thread: how to recall the initial definition (CREATE TABLE) of a table ?
Hello all at PG, Let's say I forgot the "definition" of a table (.. the original CREATE TABLE query)... how do I ask PG to tell me these definition's (int not null, text, foreign key, etc) ?? "definition" is not the correct word for this, is it ? what's the correct term ? thx jmf PS: ok, maybe I should go back to my SQL books...
am 09.01.2006, um 13:27:29 -0500 mailte Joao Miguel Ferreira folgendes: > Hello all at PG, > > Let's say I forgot the "definition" of a table (.. the original CREATE > TABLE query)... > > how do I ask PG to tell me these definition's (int not null, text, > foreign key, etc) ?? You can use pg_dump for this, example: pg_dump -t <table> -s -U <user> <database> HTH, Andreas -- Andreas Kretschmer (Kontakt: siehe Header) Heynitz: 035242/47212, D1: 0160/7141639 GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net === Schollglas Unternehmensgruppe ===
On 1/9/06 1:27 PM, "Joao Miguel Ferreira" <jmf@estg.ipvc.pt> wrote: > Hello all at PG, > > Let's say I forgot the "definition" of a table (.. the original CREATE > TABLE query)... Use pg_dump or use some program like PgAdminIII to give you the table definition. There is no "DESCRIBE mytable" like in MySQL. Sean
Why don't you use PGAdmin ? -----Original Message----- From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Joao Miguel Ferreira Sent: Monday, January 09, 2006 11:57 PM To: pgsql-novice@postgresql.org Subject: [NOVICE] how to recall the initial definition (CREATE TABLE) of a table ? Hello all at PG, Let's say I forgot the "definition" of a table (.. the original CREATE TABLE query)... how do I ask PG to tell me these definition's (int not null, text, foreign key, etc) ?? "definition" is not the correct word for this, is it ? what's the correct term ? thx jmf PS: ok, maybe I should go back to my SQL books... ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org
On 1/9/06, Sean Davis <sdavis2@mail.nih.gov> wrote: > > > > On 1/9/06 1:27 PM, "Joao Miguel Ferreira" <jmf@estg.ipvc.pt> wrote: > > > Hello all at PG, > > > > Let's say I forgot the "definition" of a table (.. the original CREATE > > TABLE query)... > > Use pg_dump or use some program like PgAdminIII to give you the table > definition. There is no "DESCRIBE mytable" like in MySQL. > > Sean > > or inside psql you can execute the \d command table to see the table definition... or even you can do in the shelll psql -U postgres -d database_name -c "\d schema_name.table_name" > file -- regards, Jaime Casanova (DBA: DataBase Aniquilator ;)
am 09.01.2006, um 10:38:06 -0500 mailte Jaime Casanova folgendes: > > > Let's say I forgot the "definition" of a table (.. the original CREATE > > > TABLE query)... > or even you can do in the shelll > > > psql -U postgres -d database_name -c "\d schema_name.table_name" > file the result is unfortunately not a valid DDL... Andreas -- Andreas Kretschmer (Kontakt: siehe Header) Heynitz: 035242/47212, D1: 0160/7141639 GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net === Schollglas Unternehmensgruppe ===
On 1/9/06, A. Kretschmer <andreas.kretschmer@schollglas.com> wrote: > am 09.01.2006, um 10:38:06 -0500 mailte Jaime Casanova folgendes: > > > > Let's say I forgot the "definition" of a table (.. the original CREATE > > > > TABLE query)... > > > or even you can do in the shelll > > > > > > psql -U postgres -d database_name -c "\d schema_name.table_name" > file > > the result is unfortunately not a valid DDL... > the question was for a way to remember the definition of the table no for the exact CREATE TABLE statement you used to create the table... if that is wath you want, then pg_dump is your solution... -- regards, Jaime Casanova (DBA: DataBase Aniquilator ;)
So much for giving a valid answer.
1. Do you want to even try using PGAdmin?
BTW.. (THAT MEANS "BY THE WAY") It’s a postgreSQL admin tool which is freely available on the web.
If you want people to post you a full-length solution on the list I don’t think that’s what a list is for. I think you need to do some research after picking up tips from users on this list.
2. Break the thread? What do you mean by references header? I left your subject intact, isnt that enough reference?
3. Id rather say your question was silly. Being too lazy to open your SQL books IS SILLY.
Being too lazy to put in some of your own effort and do some research after someone gives you an answer IS SILLY.
-----Original Message-----
From: Andreas Kretschmer [mailto:andreas.kretschmer@schollglas.com]
Sent: Monday, January 09, 2006 7:55 PM
To: Wadhwa, Amit
Subject: Re: [NOVICE] how to recall the initial definition (CREATE TABLE) of a table ?
am 09.01.2006, um 7:58:54 -0600 mailte Amit_Wadhwa@Dell.com folgendes:
> Why don't you use PGAdmin ?
1. This isn't a meaningful answer, because, for instance, i havn't
installed this
2. why do you break the thread? in your mail there are no
references-header
3. top-posting with fulltext quoting below are silly
Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47212, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===
Without aim of further discussions, this kind of situations are silly.
Best solution, get out of the list if you feel enough tough to read and support certain
discussions.
Anyway, I feel that we can be more "helpfull" providing non agressive posts, which unfortunatelly
I notice increasing.
Keep the order !
Best wishes,
Guido
So much for giving a valid answer.
1. Do you want to even try using PGAdmin?
BTW.. (THAT MEANS "BY THE WAY") It's a postgreSQL admin tool which is freely available on the web.
If you want people to post you a full-length solution on the list I don't think that's what a list is for. I think you need to do some research after picking up tips from users on this list.
2. Break the thread? What do you mean by references header? I left your subject intact, isnt that enough reference?
3. Id rather say your question was silly. Being too lazy to open your SQL books IS SILLY.
Being too lazy to put in some of your own effort and do some research after someone gives you an answer IS SILLY.
-----Original Message-----
From: Andreas Kretschmer [ mailto:andreas.kretschmer@schollglas.com]
Sent: Monday, January 09, 2006 7:55 PM
To: Wadhwa, Amit
Subject: Re: [NOVICE] how to recall the initial definition (CREATE TABLE) of a table ?
am 09.01.2006, um 7:58:54 -0600 mailte Amit_Wadhwa@Dell.com folgendes:
> Why don't you use PGAdmin ?
1. This isn't a meaningful answer, because, for instance, i havn't
installed this
2. why do you break the thread? in your mail there are no
references-header
3. top-posting with fulltext quoting below are silly
Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47212, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===
--
"Adopting the position that you are smarter than an automaticoptimization algorithm is generally a good way to achieve lessperformance, not more" - Tom Lane.
Sorry for replying to this message. I din't seem to get the first one. > Hello all at PG, > > Let's say I forgot the "definition" of a table (.. the original CREATE > TABLE query)... > > how do I ask PG to tell me these definition's (int not null, text, > foreign key, etc) ?? When in psql you can use the \d command to display the definition of any table. You can also use \? to see what other commands are available. > "definition" is not the correct word for this, is it ? what's the > correct term ? I think "definition" is ok. That's what I'd call it. > PS: ok, maybe I should go back to my SQL books... Your SQL books might not help in this situation because queries of this type are usually dependent on the client/server you are using (for example the Oracle version of what you're looking for is desc <table_name>). However, as always, Google is your friend - as are the documentation pages of the database you're using. Postgresql's happen to be very good http://www.postgresql.org/docs/8.1/static/ Regards, Andy
am 09.01.2006, um 11:40:46 -0600 mailte Amit_Wadhwa@Dell.com folgendes: > So much for giving a valid answer. > > 1. Do you want to even try using PGAdmin? Yes, but i don't like software like this. The point is: often i work remotely, and i work with Linux, and i can do many, many, many things on the command-line. > BTW.. (THAT MEANS "BY THE WAY") It's a postgreSQL admin tool which > is freely available on the web. Yes, i know. > 2. Break the thread? What do you mean by references header? I left your > subject intact, isnt that enough reference? No. My Reader sorts emails on the references-header to a tree-like structure. But this requires the References-Header. The Subject-Header isn't a useful criterion for sort mails. > > 3. Id rather say your question was silly. Being too lazy to open your My question? > -----Original Message----- I'm reading mails from top to bottom. It is silly to write the answer over the question. Do you understand? Btw.: my answer to you was a private Mail to you. Why do you quote this to the list? Andreas, sorry, if my english are bad. -- Andreas Kretschmer (Kontakt: siehe Header) Heynitz: 035242/47212, D1: 0160/7141639 GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net === Schollglas Unternehmensgruppe ===
>> 1. Do you want to even try using PGAdmin? > > Yes, but i don't like software like this. The point is: often i work > remotely, and i work with Linux, and i can do many, many, many things on > the command-line. for what it's worth: pgadmin can also be used remotely. - thomas