PostgreSQL error code
PostgreSQL error 42P06
42P06 is the SQLSTATE PostgreSQL reports for duplicate schema, in class 42, Syntax Error or Access Rule Violation.
| SQLSTATE | 42P06 |
|---|---|
| Condition name | duplicate_schema |
| Class | 42 — Syntax Error or Access Rule Violation |
Reproduce it, then fix it
The schema is already there. IF NOT EXISTS makes a setup script safe to run twice. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
CREATE SCHEMA demo;
CREATE SCHEMA IF NOT EXISTS demo;