check for table existence before dropping

Поиск
Список
Период
Сортировка
От Constantin
Тема check for table existence before dropping
Дата
Msg-id BAELIEJLNJGGCENBNILCOEAECAAA.konstant@sympatico.ca
обсуждение исходный текст
Список pgsql-novice
Hi

I am trying to to add some SQL code before a CREATE TABLE statement
that checks whether a table exists before dropping it.

This doesnt seem to work:

IF EXISTS( SELECT * FROM pg_class WHERE relname = 'cust' )
THEN
    DROP TABLE cust
    DROP SEQUENCE cust_cust_id_seq
END IF;

CREATE TABLE cust
(
    cust_id        SERIAL    PRIMARY KEY,
    name        TEXT        NOT NULL
);

Any ideas how to do this with postgresql?
Many thanks :)

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Dax Duskin"
Дата:
Сообщение: array column problem
Следующее
От: Michael Jinks
Дата:
Сообщение: Re: Postgres postmaster