Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CREATE DATABASE test IF NOT EXISTS 2

Status
Not open for further replies.

olav78

Programmer
Dec 12, 2006
3
0
0
NO
CREATE DATABASE test IF NOT EXISTS. how can I do this in postgreSQL?
 
if you are using recent version you can do something like

BEGIN;
SAVEPOINT crt;
CREATE TABLE test (id integer);

if it generates error

ROLLBACK TO SAVEPOINT crt;

and continue

if there is no error

RELEASE SAVEPOINT crt

and continue

at the end COMMIT;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top