create table if does not exists

Поиск
Список
Период
Сортировка
От Yan Cheng Cheok
Тема create table if does not exists
Дата
Msg-id 823238.36974.qm@web65702.mail.ac4.yahoo.com
обсуждение исходный текст
Ответы Re: create table if does not exists  (Chris <dmagick@gmail.com>)
Список pgsql-general
I try to have the following stored procedure, to help me create tables, if the table does not exists (Is this a good
practiceby the way?) 


if not exists(select * from information_schema.tables where table_name = 'MYTABLE') then

RAISE NOTICE 'table not there yet.';

CREATE TABLE MYTABLE
(
  "value" text NOT NULL
);

end if;


When I run for the 2nd time, 'table not there yet.' still being printed out, al though I check through pgadmin, the
MYTABLEis there. 

May I know how I can fix this?

Thanks and Regards
Yan Cheng CHEOK





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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: A maybe-bug?
Следующее
От: Chris
Дата:
Сообщение: Re: create table if does not exists