Oracle建库常用命令

时间:2021-10-05 06:23:44

Windows:用户
create temporary tablespace SP_MINES_TMP
tempfile E:OracleoradataorclSP_MINES_TMP.dbf
size 50m
autoextend on 
next 50 maxsize 2048m
extent management local;


create  tablespace SP_MINES
logging
datafile E:OracleoradataorclSP_MINES.dbf
size 50m
autoextend on 
next 50 maxsize 2048m
extent management local;


create user mines identified by 123456 
default tablespace SP_MINES
temporary tablespace SP_MINES_TMP

grant connect,resource,dba to mines;


Linux用户:
管理员用户登录oracle数据库

1、创建临时表空间
查出当前数据库临时表空间,主要是使用里面的存放路径;
select name from v$tempfile;

得到其中一条记录/opt/oracle/oradata/orcl/temp01.dbf

创建临时表空间:create temporary tablespace SP_MINES_TMP tempfile /opt/oracle/oradata/orcl/SP_MINES_TMP.dbf size 100m reuse autoextend on next 20m maxsize unlimited; 

2、创建表空间

查询出当前数据库表空间,使用里面的路径
select name from v$datafile;

得到其中一条记录/opt/oracle/oradata/orcl/system01.dbf

创建表空间:create tablespace SP_MINES datafile /opt/oracle/oradata/orcl/SP_MINES.dbf size 100M reuse autoextend on next 40M maxsize unlimited default storage(initial 128k next 128k minextents 2 maxextents unlimited);

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

create user MINES identified by 123456 default tablespace SP_MINES temporary tablespace SP_MINES_TMP;

4、赋予用户权限

grant connect,resource,dba to mines;




快速导出导入数据:
exp mines/123456@xxx.xxx.x.xxx:1521/orcl file=D:datamine-2019-12-17.dmp  log=D:datamine-2019-12-17.log

imp mines/123456@localhost:1521/orcl full=y file=D:datamine-2019-12-17.dmp