oracle 通过cmd导入数据库

--创建临时空间,设置1G大小,超出时每次自动扩展1G

create temporary tablespace LIUGAO_TEMP
tempfile 'D:\app\tablespace\LIUGAO_TEMP.dbf'
size 1024m autoextend on next 1024m maxsize UNLIMITED extent management local;

--创建表空间,指定数据库文件路径,设置20G大小,超出时每次自动扩展2G(请报错导出和导入的表空间名称一致,否则有表分区的导入会报错

create tablespace LIUGAO logging datafile 'D:\app\tablespace\LIUGAO.dbf'
size 20480m autoextend on next 2048m maxsize UNLIMITED extent management local;

--数据库文件最大31G,因此需要手工增加数据库文件,如果数据库文件小于30G,无需执行

ALTER TABLESPACE LIUGAO ADD DATAFILE 'D:\app\tablespace\LIUGAO01.dbf' size 20480m  autoextend on  next 2048m maxsize UNLIMITED;  

--创建用户

create user miffy identified by miffy
default tablespace LIUGAO
temporary tablespace LIUGAO_TEMP;

--用户授权miffy,密码miffy

grant connect,resource,dba to miffy;

--用创建的用户名和密码登录oracle数据库,登陆成功即可

sqlplus 用户名/密码

--退出sqlplus,在命令行界面使用imp导入dmp

imp miffy/miffy@orcl file=C:\数据库备份\liugao20201021.dmp full=y ignore=y;

full=y 是导入文件中全部内容

ignore=y相当于,如果没有的表,创建并倒入数据,如果已经有的表,忽略创建的,但不忽略倒入

buffer 缓冲器大小的配置

-- 删除表空间,如果其他表空间中的表有外键等约束关联到了本表空间中的表的字段,就要加上CASCADE CONSTRAINTS
drop tablespace tablespace_name including contents and datafiles CASCADE CONSTRAINTS;

--oracle 查看表空间以及剩余量

SELECT a.tablespace_name "表空间名", 
total "表空间大小", 
free "表空间剩余大小", 
(total - free) "表空间使用大小", 
total / (1024 * 1024 * 1024) "表空间大小(G)", 
free / (1024 * 1024 * 1024) "表空间剩余大小(G)", 
(total - free) / (1024 * 1024 * 1024) "表空间使用大小(G)", 
round((total - free) / total, 4) * 100 "使用率 %" 
FROM (SELECT tablespace_name, SUM(bytes) free 
FROM dba_free_space 
GROUP BY tablespace_name) a, 
(SELECT tablespace_name, SUM(bytes) total 
FROM dba_data_files 
GROUP BY tablespace_name) b 
WHERE a.tablespace_name = b.tablespace_name 

--查询当前用户所属表的大小

Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name

posted @ 2020-10-26 15:47  摸鱼儿  阅读(569)  评论(0编辑  收藏  举报