X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 57807D1B510 for ; Mon, 20 Oct 2003 18:34:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 81265-06 for ; Mon, 20 Oct 2003 15:33:30 -0300 (ADT) Received: from THOR.goeci.com (thor.goeci.com [66.28.220.99]) by svr1.postgresql.org (Postfix) with ESMTP id 5F595D1B501 for ; Mon, 20 Oct 2003 15:33:28 -0300 (ADT) Received: by THOR.goeci.com with Internet Mail Service (5.5.2653.19) id <47P81LPA>; Mon, 20 Oct 2003 14:33:26 -0400 Message-ID: <2D92FEBFD3BE1346A6C397223A8DD3FC092444@THOR.goeci.com> From: Murthy Kambhampaty To: 'Sam Carleton' , pgsql-admin@postgresql.org Subject: Re: sql scripts Date: Mon, 20 Oct 2003 14:33:24 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/244 X-Sequence-Number: 10805 If it's a bash script you could use: ##### SomeTable= TableTest=$(psql -d -U -ntc "select relname from pg_class where relname='$SomeTable'") [[ -n "$TableTest" ]] && psql -d -U -nc "drop table $SomeTable" ##### It's not quite "in postgres's sql", but it could get the job done >-----Original Message----- >From: Sam Carleton [mailto:ehc@linux-info.net] >Sent: Saturday, October 18, 2003 22:37 >To: pgsql-admin@postgresql.org >Subject: [ADMIN] sql scripts > > >I am new to postgres and your mailing lists, please let me know if I >am posting in the wrong list. > >I am working on creating my first database in Postgres. In the >script that will create all the tables for the firs time, I would >like to have a conditional statement to delete a table, if it >already exists. I know the other databases create such a condtional >statement for you when you export the schema. What would such a >conditional statement look like in Postgres's sql? > >sam > >---------------------------(end of >broadcast)--------------------------- >TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly >