-- 创建用户
CREATE USER dbUser WITH PASSWORD 'Abc123....';
-- 数据库授权用户,此时用户还是没有读写权限,需要授权表
GRANT ALL PRIVILEGES ON DATABASE dbName TO dbUser;
-- 当前数据库下 public schema 的表都授权给 dbUser
GRANT ALL PRIVILEGES ON all tables in schema public TO dbUser;
-- 指定表授权
GRANT SELECT ON TABLE tableName TO dbUser;
-- 指定表所有权限
GRANT ALL ON tableName TO dbUser;
-- 撤销表权限
REVOKE privileges ON tableName FROM dbUser;