oracle数据库用户、表空间创建、删除、授权

来源:互联网 发布:数据库精品课程 王珊 编辑:程序博客网 时间:2024/04/29 07:15
--- 创建表空间
-- 分为四步 
-- 第1步:创建临时表空间  
create temporary tablespace chezhi_temp
tempfile 'D:\app\chezhi\oradata\orcl\chezhi_temp.dbf'   -- 临时表空间存放路径
size 50m  
autoextend on  
next 50m maxsize 20480m  
extent management local;  
 
-- 第2步:创建数据表空间  
create tablespace chezhi_data
logging  
datafile 'D:\app\chezhi\oradata\orcl\chezhi_data.dbf'  -- 数据表空间存放路径
size 50m  
autoextend on  
next 50m maxsize 20480m    -- 可以指定表空间的最大容量为2048M
extent management local;  
 
-- 第3步:创建用户并指定表空间  
create user chezhi identified by chezhi
default tablespace chezhi_data
temporary tablespace chezhi_temp;  
 
-- 第4步:给用户 chezhi 授予权限  
grant connect,resource,dba to chezhi;
-- 或
grant connect,resource,dba,create any view,select any table,create any procedure,unlimited tablespace to chezhi;   
 
-- 删除表空间、用户
-- 删除某用户及表空间的步骤
--步骤一:  删除user  
drop user zkxttest cascade;
--说明: 删除了user,只是删除了该user下的schema objects,是不会删除相应的tablespace的。 
--cascade级联删除,被删除用户的权限以及由被删除用户授予出去的权限会一并删除   
 
--步骤二: 删除tablespace 
drop tablespace zkxttest_temp including contents and datafiles;   --同时会把对应的表空间文件删除

-- 修改表空间大小
alter database datafile 'D:\app\chezhi\oradata\orcl\chezhi_data.dbf' autoextend on next 50M maxsize unlimited; -- 修改为无限大
1 0
原创粉丝点击