Oracle学习随笔——表空间/权限/用户/角色设置

1、表空间
1.1、创建数据表空间。
create tablespace tablespace_name datafile 'datafile1.dbf' size 20M;
创建一个名称为tablespace_name,数据文件名称为datafile1.dbf,大小为20M的表空间。
1.2、创建临时表空间
create temporary tablespace tablespace_name tempfile 'tempfile1.dbf' size 20M;
创建一个名称为tablespace_name,数据文件名称为tempfile1.dbf,大小为20M的临时表空间。
1.3、删除表空间
drop tablespace tablesapce_name;
删除名字为tablespace_name的表空间。
1.4、表空间的数据字典
系统表空间字典 dba_tablespaces
用户表空间字典 user_tablespaces
1.5、修改用户默认和临时表空间
alter user user_name default tablespace tablespace_name1 temporary tablespace tablespace_name2;
将用户user_name的默认表空间修改为tablespace_name1,临时表空间修改为tablespace_name2。
1.6、设置表空间的状态【联机/脱机】、【只读/可读写】
alter tablespace tablespace_name online[联机]/offline[脱机]/read only [只读] /read write [可读写];
1.7、增加表空间的数据文件
alter tablespace tablespace_name add datafile 'filename.dbf' size 20M;
给表空间tablespace_name 增加一个名字为filename.dbf,大小为20M的数据文件。
1.8、删除表空间的数据文件【不能删除表空间第一个创建的数据文件】
alter tablespace tablespace_name drop datafile 'dataname.dbf';
从表空间tablespace_name中删除dataname.dbf的数据文件。
1.9、删除表空间
语法:drop tablespace tablespace_name [including contents];
其中including contents表示把表空间和数据全部删除。
1.10、查询文件数据字典
系统数据文件字典 dba_data_files
系统临时文件字典 dba_temp_files
select * from dba_data_files/dba_temp_files;

2、创建用户(密码不能是数字开头)
create user user_name identified by password default tablesapce tablespace_name1 temporary tablesapce tablespace_name2;
创建了一个名字为user 密码为password,默认表空间为tablespace_name1,临时表空间tablespace_name2的用户。

3、查询系统用户数据字典
系统用户字典dba_user
当前用户字典user_user

4、权限
系统权限的数据字典 system_privilege_map
系统对象权限的数据字典 table_privilege_map
系统常见的对象权限 select,insert,delete,update,all等,其中all表示所有权限;
例如:将scott用户下的emp表的select和update的权限授予manager角色
grant select,update on scott.emp to manager;
回收权限
例如:将scott用户下的emp表的update的权限从manager角色收回
revoke update on scott.emp to manager;

5.1、授予权限【系统可以级联授予,但不能级联收回】
grant 权限 to 用户 [with admin option];
当授予某个权限给用户后,用户可以把这个权限授权给下一个用户;
例如:给用户授权一个表空间的权限[unlimited tablespace]表示不限制表空间,[any table] 表示任意表
grant unlimited tablespace to user;
给用户user授权一个 不限制表空间的权限
5.2、授予对象权限【级联授予,但也收回】
grant 操作 on 对象  to  用户 [with grant option];

6、创建角色,并授予权限,撤销权限,删除角色
create role 角色名称;--创建一个角色
grant 权限 to 角色名称; --给角色授予权限
grant 角色名称 to 用户;--将角色赋予用户
revoke 角色 from 用户;--撤销用户的权限
drop role 角色名称;--删除角色
查询用户被授予的权限
select * from dba_sys_privs; 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值