Could you please advise why when trying to create a table like this:
CREATE TABLE IF NOT EXISTS doc.bgp_communities (
i SERIAL PRIMARY KEY,
comm_name TEXT NOT NULL,
comm_value TEXT NOT NULL,
label TEXT NOT NULL,
used_as TEXT NOT NULL,
modified_on TIMESTAMPZ DEFAULT NOW(),
UNIQUE ( comm_value ),
CHECK ( (comm_value SIMILAR TO '%:%') OR (comm_value SIMILAR TO '%:%:%') ),
CHECK ( used_as IN ('bgp-customer','destination','dtv-peer','free-peer','generic','infrastructure','origin','private-peer','public-peer','traffic-eng','voip-peer') )
) ;
Before that I have created the schemas as follows:
ip_spotlight-# CREATE SCHEMA doc
ip_spotlight-# CREATE SCHEMA net
ip_spotlight-# ALTER DATABASE ip_spotlight SET search_path TO doc,net
I am getting the following error message:
ERROR: schema "doc" does not exist
Could you please advise what I am doing wrong ?
PS: my user "app" is configured like:
app | Superuser, No inheritance, Create role, Create DB, Replication | {}
EDIT
app@[local]:5432 ip_spotlight# CREATE SCHEMA doc ;
CREATE SCHEMA
Time: 1.492 ms
app@[local]:5432* ip_spotlight# CREATE SCHEMA net ;
CREATE SCHEMA
Time: 0.641 ms
app@[local]:5432* ip_spotlight# ALTER DATABASE ip_spotlight SET search_path TO doc,net ;
ALTER DATABASE
Time: 1.036 ms
# CREATE TABLE IF NOT EXISTS doc.bgp_communities (
ip_spotlight(# i SERIAL PRIMARY KEY,
ip_spotlight(# comm_name TEXT NOT NULL,
ip_spotlight(# comm_value TEXT NOT NULL,
ip_spotlight(# label TEXT NOT NULL,
ip_spotlight(# used_as TEXT NOT NULL,
ip_spotlight(# modified_on TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
ip_spotlight(# UNIQUE ( comm_value ),
ip_spotlight(# CHECK ( (comm_value SIMILAR TO '%:%') OR (comm_value SIMILAR TO '%:%:%') ),
ip_spotlight(# CHECK ( used_as IN ('bgp-customer','destination','dtv-peer','free-peer','generic','infrastructure','origin','private-peer','public-peer','traffic-eng','voip-peer') )
ip_spotlight(# ) ;
ERROR: schema "doc" does not exist
Time: 0.686 ms
app@[local]:5432! ip_spotlight# \dn
ERROR: current transaction is aborted, commands ignored until end of transaction block
app@[local]:5432! ip_spotlight#
ip_spotlight-# CREATE SCHEMA doc ip_spotlight-# CREATE SCHEMA net ip_spotlight-# ALTER DATABASE ip_spotlight SET search_path TO doc,netneed ';' at each command end, to beip_spotlight-# CREATE SCHEMA doc; ip_spotlight-# CREATE SCHEMA net; ip_spotlight-# ALTER DATABASE ip_spotlight SET search_path TO doc,net;alter database ... set ...;does not affects current session. You need to reconnect to get it or executeset ...;just afteralter database ... set ...;CREATE SCHEMAstatement in a transaction? If yes, then you are expected toCOMMITthat transaction, as in PostgreSQL, the DDL statements (also) take part in the transaction. (The space between your statements may imply that you are actually running 2 separate transactions, is it so?).