CREATE OR REPLACE for a CREATE TABLE Statement - PostgreSQL
Posted on 2007-10-12
In PostgreSQL, when writing a CREATE FUNCTION statement, you can add the statement OR REPLACE into the CREATE line, so it looks like this CREATE OR REPLACE FUNCTION. This checks if the function exists, and if it doesn't it creates it. If the function does exist, then it replaces it.
With a table CREATE statement, I tried to do the same thing, but I received a syntax error on the OR REPLACE.
Is there a way to check to see if a table exists, if so, then DROP it and then Re-Create it. I want my script to be able to run on databases that don't have the table created yet as well as databases that have the table created, but I need to update the table.