Thread
-
RE: Test for existence of Table
Craig L. Ching <cching@mqsoftware.com> — 2001-01-04T23:37:33Z
Yeah, DROP TABLE employees CREATE TABLE employees ;-) Craig -----Original Message----- From: Soma Interesting [mailto:dfunct@telus.net] Sent: Thursday, January 04, 2001 1:40 PM To: pgsql-general@postgresql.org Subject: [GENERAL] Test for existence of Table Can I test for an existing table before issuing the "CREATE TABLE" command? IF EXISTS employees{ DROP TABLE employees } CREATE TABLE employees Can you provide an example of this. I couldn't find this in the manual or Bruce's book - did I not look hard enough ? :) - - - - - - - - - - - WARNING: Some experts believe that use of any keyboard may cause serious injury. Consult Users Guide. dfunct@telus.net -
Re: Test for existence of Table
Gregory Wood <gregw@com-stock.com> — 2001-01-05T03:11:31Z
> DROP TABLE employees Error: ERROR: Relation 'employees' does not exist And execution halts.... which is I believe why he wanted to check for the existence before trying to DROP. I'd love to know if this exists as well... would come in very handy during development time. Greg > Yeah, > > DROP TABLE employees > CREATE TABLE employees > > ;-) > > Craig > > -----Original Message----- > From: Soma Interesting [mailto:dfunct@telus.net] > Sent: Thursday, January 04, 2001 1:40 PM > To: pgsql-general@postgresql.org > Subject: [GENERAL] Test for existence of Table > > > Can I test for an existing table before issuing the "CREATE TABLE" command? > > IF EXISTS employees{ > DROP TABLE employees > } > CREATE TABLE employees > > Can you provide an example of this. I couldn't find this in the manual or > Bruce's book - did I not look hard enough ? :) > > > - - - - - - - > - - - - > WARNING: Some experts believe that use of any keyboard may cause > serious injury. Consult Users Guide. > > dfunct@telus.net > -
Re: Test for existence of Table
Anthony E . Greene <agreene@pobox.com> — 2001-01-05T06:11:51Z
On Thu, 04 Jan 2001 22:11:31 Gregory Wood wrote: >> DROP TABLE employees >Error: ERROR: Relation 'employees' does not exist > >And execution halts.... which is I believe why he wanted to check for the >existence before trying to DROP. I'd love to know if this exists as well... >would come in very handy during development time. > >Greg I just tested this with "psql < script.sql" and execution did not stop. There may be contexts where this error causes execution to stop but it works at the command line with psql. That implies that it works within psql using "\i script.sql", which I have also found to be true. Tony -- Anthony E. Greene <agreene@pobox.com> <http://www.pobox.com/~agreene/> PGP Key: 0x6C94239D/7B3D BD7D 7D91 1B44 BA26 C484 A42A 60DD 6C94 239D Chat: AOL/Yahoo: TonyG05 ICQ: 91183266 Linux. The choice of a GNU Generation. <http://www.linux.org/>