1、创建用户,设置密码以及其他参数。 【uname为自己创建的用户名】
create user uname identified by password -----数字要加双引号,如: "123456"
default tablespace 表空间名
temporary tablespace 临时表空间名
profile default
quota 50m on 表空间名;
1.1 修改用户,将create改为alter即可
alter user uname
identified by password -----数字要加双引号,如: "123456"
default tablespace 表空间名
temporary tablespace 临时表空间名
profile default
quota 50m on 表空间名;
1.2 删除用户(所有的数据库对象同时删除)
drop user uname cascade;
2、创建角色。【rname 为自己创建的角色名】
create role rname identified by password;
2.1 设置角色生效
set role rname identified by password;
2.2 给角色授权
grant dba to rname;
2.3 将授权的角色授权给用户
grant rname to uname with admin option; ---被授权的用户也可给其他用户授权
2.4 回收权限
revoke dba from uname;
2.5 删除角色
drop role rname;
3、创建profile配置文件。【pfname 为自己创建的配置文件名】
下面是一个简单的例子:
只能连接两个会话,允许占用2分钟空闲时间
2次登陆失败则锁定5分钟
密码有效期30天,宽限3天
create profile pfname limit
sessions_per_user 2
idle_time 2
failed_login_attempts 2
password_lock_time 5
password_life_time 30
password_grace_time 3;
3.1 修改配置文件信息只需将create改为alter
alter profile pfname limit
sessions_per_user 2
idle_time 2
failed_login_attempts 2
password_lock_time 5
password_life_time 30
password_grace_time 3;
3.2 删除配置文件
drop profile pfname;
3.3 将配置文件分给用户
alter user sxx profile pf_sxx;
也可设置为默认的profile配置文件
alter user sxx profile default;
3.4 查看配置信息
select * from dba_profiles;
3.5 解除用户锁定
alter user sxx account unlock;
3.6 查看是否启用资源限制
show parameter limit;
若是false,则启用资源限制
alter system set resource_limit=true;