-- 创建用户req CREATEUSER req WITH PASSWORD 'password';
-- 授予用户对数据库的所有权限 GRANTALL PRIVILEGES ON DATABASE your_database TO req;
-- 切换到新创建的数据库 \c your_database
-- 授予用户对数据库中所有 schema 和对象的所有权限 GRANTALL PRIVILEGES ON SCHEMA public TO req; -- 重复这行语句以适用于多个 schema GRANTALL PRIVILEGES ONALL TABLES IN SCHEMA public TO req; GRANTALL PRIVILEGES ONALL SEQUENCES IN SCHEMA public TO req;
-- 确保未来创建的对象也授予用户权限 ALTERDEFAULT PRIVILEGES IN SCHEMA public GRANTALL PRIVILEGES ON TABLES TO req; ALTERDEFAULT PRIVILEGES IN SCHEMA public GRANTALL PRIVILEGES ON SEQUENCES TO req;