一、完整命令
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;
四、参考资料
时间: 2024-11-06 18:50:41