ORACLE备份与还原
----------------------------------*备份数据库*----------------------------------
1、WINDOWS(图标)+R --> CMD
2、SQLPLUS RSGL_BJKW/RSGL@127.0.0.1/ORCL
3、SHOW PARAMETER DEFERRED_SEGMENT_CREATION;(如果为TRUE,则将该参数改为FALSE)
4、ALTER SYSTEM SET DEFERRED_SEGMENT_CREATION=FALSE;
5、SELECT 'ALTER TABLE '||TABLE_NAME||' ALLOCATE EXTENT;' FROM USER_TABLES WHERE NUM_ROWS=0 OR NUM_ROWS IS NULL;
6、EXP RSGL_BJKW/RSGL@127.0.0.1/ORCL FILE=D:\RSGL_BJKW\RSGL_BJKW.DMP LOG=D:\RSGL_BJKW\RSGL_BJKW.LOG OWNER=RSGL_BJKW
---------------------------------*删除原表空间*---------------------------------
1、WINDOWS(图标)+R --> CMD
1、SQLPLUS /NOLOG
2、CONN /AS SYSDBA
3、DROP USER RSGL_BJKW CASCADE;
4、DROP TABLESPACE RSGL_BJKW INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS;
5、重启ORACLE服务
6、手动删除表空间文件(*.DBF)
----------------------------------*还原数据库*----------------------------------
1、WINDOWS(图标)+R --> CMD
2、SQLPLUS /NOLOG
3、CONN /AS SYSDBA
4、CREATE TEMPORARY TABLESPACE RSGL_BJKW_TEMP TEMPFILE 'D:\DataBase\Oracle\TableSpace\RSGL_BJKW_TEMP.DBF' SIZE 500M AUTOEXTEND ON NEXT 50M MAXSIZE 20480M EXTENT MANAGEMENT LOCAL;
5、CREATE TABLESPACE RSGL_BJKW_DATA LOGGING DATAFILE 'D:\DataBase\Oracle\TableSpace\RSGL_BJKW_DATA.DBF' SIZE 500M AUTOEXTEND ON NEXT 50M MAXSIZE 20480M EXTENT MANAGEMENT LOCAL;
6、CREATE USER RSGL_BJKW IDENTIFIED BY RSGL DEFAULT TABLESPACE RSGL_BJKW_DATA TEMPORARY TABLESPACE RSGL_BJKW_TEMP;
7、GRANT CONNECT,RESOURCE,DBA TO RSGL_BJKW;
8、IMP FILE=H:\RSGL_BJKW\RSGL_BJKW_2020-02-13.DMP LOG=H:\RSGL_BJKW\RSGL_BJKW_2020-02-13.LOG STATISTICS=NONE USERID=RSGL_BJKW/RSGL@127.0.0.1/ORCL BUFFER=100000000 COMMIT=NO FULL=YES GRANTS=YES IGNORE=YES INDEXES=YES ROWS=YES SHOW=NO CONSTRAINTS=YES