oracle数据库创建表空间和用户并赋予权限

管理员用户登录oracle数据库

1、创建临时表空间
select name from v$tempfile;查出当前数据库临时表空间,主要是使用里面的存放路径;
得到其中一条记录/opt/oracle/oradata/orcl/temp01.dbf
创建临时表空间:create temporary tablespace plncontrol_temp tempfile ‘/opt/oracle/oradata/orcl/plncontrol_temp.dbf’ size 100m reuse autoextend on next 20m maxsize unlimited;

2、创建表空间
select name from v$datafile;查询出当前数据库表空间,使用里面的路径
得到其中一条记录/opt/oracle/oradata/orcl/system01.dbf
创建表空间:create tablespace plncontrol datafile ‘/opt/oracle/oradata/orcl/plncontrol.dbf’ size 100M reuse autoextend on next 40M maxsize unlimited;

3、创建用户并指定表空间
create user plncontrol identified by plncontrol default tablespace plncontrol temporary tablespace plncontrol_temp;

4、赋予用户权限
grant connect,resource,dba to plncontrol;

5、删除表空间和用户
删除是创建的相反顺序,先删除用户,再删除表空间:
drop user plncontrol cascade;
drop tablespace plncontrol including contents and datafiles;
如果删除表空间时是如下语句:
drop tablespace test1;
则需要在相应路径下手动删除dbf文件。

6、修改用户密码、解锁用户
登录sys用户:sqlplus / as sysdba
修改用户密码:alter user user identify by password
解锁账户:alter user 账户 account unlock

7、查询表空间所在的路径
select * from dba_data_files

8、导出导入dmp

指定表:
exp test/oracle  file=/u01/b.dmp tables=mema.t1,mema.t3
imp user/password file=file.dmp TABLES=t1,T2;

全部:
exp test/test@10.10.15.103:1521/orcl file=d:/20150923.dump owner=(test) consistent=y;
imp test1/test1@localhost:1521/orcl file=d:/20150923.dump fromuser=(test) touser=(test1) ignore=y;

猜你喜欢

转载自blog.csdn.net/borntodieee/article/details/79044467