From: | Jennifer Trey <jennifer(dot)trey(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Create table if not exists ... how ?? |
Date: | 2010-07-19 16:33:39 |
Message-ID: | AANLkTikaCWrB_Dd-s4adMisqd-YR3wMudBi3yLYLcE1V@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I can't figure out the correct syntax...
I have this, but it just keeps complaining about the IF
IF NOT EXISTS (SELECT table_name FROM information_schema.tables where
table_name = 'post_codes')
THEN
CREATE TABLE post_codes
(
area character varying(10) NOT NULL,
district character varying(10) NOT NULL,
sector character varying(10) NOT NULL,
CONSTRAINT post_codes_pkey PRIMARY KEY (area, district, sector)
)
WITH (
OIDS=FALSE
);
ALTER TABLE post_codes OWNER TO postgres;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
ERROR: syntax error at or near "IF"
LINE 1: IF NOT EXISTS (SELECT table_name FROM information_schema.tab...
^
********** Error **********
ERROR: syntax error at or near "IF"
SQL state: 42601
Character: 1
How should this be written ?
Thanks, Jen
From | Date | Subject | |
---|---|---|---|
Next Message | Raymond O'Donnell | 2010-07-19 16:39:12 | Re: Create table if not exists ... how ?? |
Previous Message | arno | 2010-07-19 16:25:47 | Re: index scan and functions |