Question :
I create a new tablespace using the following script:
CREATE SCHEMA semiarido;
CREATE ROLE semiarido PASSWORD 'senha';
GRANT CREATE ON SCHEMA semiarido TO semiarido;
GRANT USAGE ON SCHEMA semiarido TO semiarido;
alter role semiarido set default_tablespace = semiarido;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA semiarido TO semiarido;
ALTER ROLE "semiarido" WITH LOGIN;
When I connect to the database using psql or a python script, I get the following warning:
WARNING: invalid value for parameter “default_tablespace”: “semiarido”
DETAIL: Tablespace “semiarido” does not exist.
However, it works, that is, the user is connected to the correct database and see “semiarido” as the default database.
So what’s the problem? Why I’m getting this warning?
Answer :
It seems you’re confusing schemas and tablespaces. A schema defines a namespace whereas a tablespace points to a path on disk where data files are stored.
SET default_tablespace = name
refers to a tablespace that would have been created with CREATE TABLESPACE
.
A default schema can be assigned to a user through search_path
, see Schemas in the documentation.