Search Postgresql Archives

Re: Create table if not exists ... how ??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/19/2010 09:33 AM, Jennifer Trey wrote:
> 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

Probably better to do:

DROP TABLE IF EXISTS post_codes;
CREATE TABLE post_codes(...);

See:
  http://www.postgresql.org/docs/8.4/interactive/sql-droptable.html

HTH,

Joe

-- 
Joe Conway
credativ LLC: http://www.credativ.us
Linux, PostgreSQL, and general Open Source
Training, Service, Consulting, & 24x7 Support

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux