Warning message: invalid value for parameter "default_tablespace" in postgres 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 &quot;semiarido&quot; WITH LOGIN;

When I connect to the database using psql or a python script, I get the following warning:
WARNING:  invalid value for parameter &quot;default_tablespace&quot;: &quot;semiarido&quot;
DETAIL:  Tablespace &quot;semiarido&quot; does not exist.
However, it works, that is, the user is connected to the correct database and see &quot;semiarido&quot; as the default database.
So what's the problem? Why I'm getting this warning?
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.