Re: PostreSQL SQL for MySQL SQL

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Chuck Esterbrook <echuck(at)mindspring(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PostreSQL SQL for MySQL SQL
Date: 2001-02-06 18:03:14
Message-ID: 200102061803.NAA03483@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Hi,
>
> I'm fairly new to PostreSQL, coming from MySQL. My Python application
> generates these MySQL commands:
>
> drop database if exists Foo;
> create database Foo;
> use Foo;
>
> Using the PostgreSQL online docs, my closest translation is:
>
> drop database Foo;
> create database Foo;
>
> What I'm missing is:
> * "if exists" for the drop, in order to avoid an error the very first time
> this program runs
> * the "use Foo;"
>
> Can I do these things in PostreSQL from SQL (e.g., not from the command line)?

Just let the DROP fail if it does not already exist.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brice Ruth 2001-02-06 18:07:03 Re: SQL Join - MySQL/PostgreSQL difference?
Previous Message Peter Eisentraut 2001-02-06 17:50:59 Re: Attribute inhrel not found