创建用户案例
l
创建用户(USER)
l
删除用户
l
修改密码
l
创建角色(ROLE)
l
删除角色
l
给用户分配角色
|
说明:用
sys
用户以
sysdba
的身份登录
SQL*Plus Worksheet
,运行下面脚本,实现对用户的简单管理。
l
创建用户 (USER)
--
创建一个用户
Sam
,密码是
Sam
create user sam identified by sam;
|
l
删除用户
--
删除用户
Sam
drop user sam;
|
l
修改密码
--
修改
Sam
的密码为
1234
alter user sam identified by 1234;
|
l
创建角色(ROLE)
--
创建角色
manager
create role manager;
|
l
删除角色
--
删除角色
manager
Drop role manager;
|
l
给用户分配角色
--
给用户
Sam
分配角色
manager
grant manager to sam;
|
l
给用户撤销角色
--
给用户
Sam
撤销角色
manager
revoke manager from sam;
|
conn sys
/
cms
@cms
as
sysdba
CREATE
USER
"CMS" PROFILE "
DEFAULT
"
IDENTIFIED
BY
"cms"
DEFAULT
TABLESPACE "USERS"
TEMPORARY
TABLESPACE "
TEMP
"
ACCOUNT UNLOCK;
GRANT
"CONNECT"
TO
"CMS";
GRANT
"DELETE_CATALOG_ROLE"
TO
"CMS";
GRANT
"DM_CATALOG_ROLE"
TO
"CMS";
GRANT
"EXECUTE_CATALOG_ROLE"
TO
"CMS";
GRANT
"EXP_FULL_DATABASE"
TO
"CMS";
GRANT
"HS_ADMIN_ROLE"
TO
"CMS";
GRANT
"IMP_FULL_DATABASE"
TO
"CMS";
GRANT
"OLAP_USER"
TO
"CMS";
GRANT
"RECOVERY_CATALOG_OWNER"
TO
"CMS";
GRANT
"RESOURCE"
TO
"CMS";
GRANT
"SCHEDULER_ADMIN"
TO
"CMS";
GRANT
"SELECT_CATALOG_ROLE"
TO
"CMS";