Oracle学习笔记_05_ 一个创建表空间、创建用户、授权的完整过程

一、完整命令

 

su - oracle
sqlplus /nolog
conn /as sysdba

create tablespace scaninvoice logging datafile '/u01/app/oracle/oradata/mas/scaninvoice.dbf' size 200M autoextend on next 100m  extent management local;
create temporary tablespace scaninvoice_tmp tempfile '/u01/app/oracle/oradata/mas/scaninvoice_tmp.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;

create user  username  identified by password default tablespace scaninvoice 
temporary tablespace scaninvoice_tmp;        

grant dba to trainhec ;
grant dba,create session,resource,connect to trainhec ;
exit;  

 

 

二、完整过程

1.以root用户登录linux,然后切换到oracle用户,以sysdba的身份登录oracle

# su - oracle
$ sqlplus /nolog
SQL> conn /as sysdba

 

2.创建表空间和临时表空间

2.1 表空间: 一般在开发情况下,我们当然不会使用用户的默认表空间,所以这时我们需要创建一个表空间. 

create tablespace scaninvoice logging datafile '/u01/app/oracle/oradata/mas/scaninvoice.dbf' size 200M autoextend on next 100m  extent management local;

 

注:datafile后面是表空间的物理存储路径,文件名的后缀可以随便. 若没有dbf文件,则系统会自动创建。

2.2 临时表空间

create temporary tablespace scaninvoice_tmp tempfile '/u01/app/oracle/oradata/mas/scaninvoice_tmp.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;

 

3.创建用户

create user  username  identified by password;    //使用默认表空间 USER

create user  username  identified by password default tablespace scaninvoice 
temporary tablespace scaninvoice_tmp;            //指定默认表空间和临时表空间  (推荐)

 

4.授权用户

grant dba to trainhec ;
grant dba,create session,resource,connect to trainhec ;
exit;

 

三、附加命令

1.修改用户密码

alter user username  identified by password; 

 

2.查看所有用户所在的表空间

默认情况下用户创建好后系统会默认给该用户分配一个表空间(users); 我们可以通过下面的sql语句来查看一下所有用户所在的表空间. 

select username,default_tablespace from dba_users;  

 

3.将表空间分配给用户

alter user scaninvoice default tablespace scaninvoice;  

 

 

四、参考资料

1. Oracle创建表空间、创建用户以及授权 

 

转载于:https://www.cnblogs.com/shirui/p/7879641.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值