oracle创建表空间和用户

1、创建数据表空间

create tablespace 数据表空间名称
    logging
    datafile  
'路 径 ( 预 先 创 建 好 ) \数 据 文 件 名 称.dbf'
     size 100M  --指定大小为100M
     reuse autoextend on next 20m maxsize 1024M --允许自动扩展数据文件,数据大小超过100M,自动增长20M,最大可增长到1024M,若不扩展,则替换语句为 :reuse autoextend off
     /**下面是可选指令,看需求而定*/
     extent management local autoallocate--本地管理方式(1、autoallocate:自动分配;2、uniform size *m:定制分配; 
     segment space management auto  --段管理方式(1、auto:自动管理;2、manual:手动管理)


 2、创建临时表空间

create temporary tablespace 临时表空间名称
    tempfile  '路 径 (预 先 创 建 好 ) \临 时 文 件 名 称.dbf' 
    size 20M;


 

3、 创建用户并指定表空间

create user 用户名 identified by 密码
default tablespace 数据表空间名称
temporary tablespace 临时表空间名称


 

4、给用户授权

 grant connect,resource,dba to 用户名;

/**

除此之外还可授权:

         create table
         ,select any table
         ,select any dictionary 
         ,create public synonym
         ,create sequence
         ,create trigger 
         ,create type
         ,create view
         ,create indextype
         ,create job
         ,create materialized view
         ,create procedure

*/


 

 5、删除表空间以及对应的数据文件

drop tablespace 表空间名称 including contents and datafiles; --执行该语句,再到本地把指定路径下的数据文件删除即可


 

 6、修改表空间

(1)该把表空间设置为脱机状态
         alter tablespace 表空间名称 offline normal;
(2)创建新的文件夹,并且复制旧的test01.dbf到新的文件夹下
        alter tablespace 表空间名称 rename datafile
               '
旧路径\test01.dbf'
        to
               '
新路径\test02.dbf';
(3)最后把表空间设置为联机状态
         alter tablespace 表空间名称 online;


 

7、修改用户表空间

alter user 用户名  default tablespace 新的表空间;


 

8、 删除用户

drop user  用户名 cascade  --只删除用户,不删除表空间

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值