# 使用数据库用户登录sysdba
sqlplus USERNAME/PASSWORD as SYSDBA
# 创建用户QDDB_QUERY,Aa123456
CREATE USER QDDB_QUERY IDENTIFIED BY Aa123456;
# 创建用户并解锁
CREATE USER QDDB_QUERY IDENTIFIED BY Aa123456 ACCOUNT UNLOCK;
# 单独解锁账户
ALTER USER QDDB_QUERY ACCOUNT UNLOCK;
# 赋予登录权限
GRANT CREATE SESSION TO QDDB_QUERY;
# 创建查询角色DEMAND_QUERY
CREATE ROLE DEMAND_QUERY;
# 给角色赋值权限
GRANT SELECT ON NAMESPACE.TABLE_NAME TO DEMAND_QUERY;
# 将角色授予用户
GRANT DEMAND_QUERY TO QDDB_QUERY;
# 撤销权限
REVOKE 权限 FROM 角色名;
REVOKE 角色名 FROM 用户名;
oracle 11g创建角色并分配用户
![](https://img-home.csdnimg.cn/images/20240711042549.png)