1.逻辑导入:
/*第1步:创建临时表空间 **/ create temporary tablespace user_temp1 tempfile 'D:appAdministratororadatashengrenshetinguser_temp1.dbf' size 50m autoextend on next 50m maxsize 30480m extent management local; /*第2步:创建数据表空间 */ create tablespace user_data1 logging /*logging 是对象的属性,创建数据库对象时,oracle 将日志信息记录到练级重做日志文件中。代表空间类型为永久型 */ datafile 'D:appAdministratororadatashengrenshetinguser_data1.dbf' size 50m autoextend on /*autoextend on 表空间大小不够用时自动扩展*/ next 50m maxsize 30480m /*next 50m 自动扩展增量为50MB */ extent management local; /*extent management local 代表管理方式为本地*/ /*创建拓展表空间*/ CREATE TABLESPACE TS_HNDSZG_PUBLIC LOGGING DATAFILE 'E:oraclescdbscdbTS_HNDSZG_PUBLIC01.DBF' SIZE 1000M AUTOEXTEND ON NEXT 1000M MAXSIZE Unlimited, 'E:oraclescdbscdbTS_HNDSZG_PUBLIC02.DBF' SIZE 1000M AUTOEXTEND ON NEXT 1000M MAXSIZE Unlimited, 'E:oraclescdbscdbTS_HNDSZG_PUBLIC03.DBF' SIZE 1000M AUTOEXTEND ON NEXT 1000M MAXSIZE Unlimited, 'E:oraclescdbscdbTS_HNDSZG_PUBLIC04.DBF' SIZE 1000M AUTOEXTEND ON NEXT 1000M MAXSIZE Unlimited, 'E:oraclescdbscdbTS_HNDSZG_PUBLIC05.DBF' SIZE 1000M AUTOEXTEND ON NEXT 1000M MAXSIZE Unlimited EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ; ----------------------------------------------------------------------- /*修改或执行导入,提示的时候增加表空间*/ ALTER TABLESPACE USERS ADD DATAFILE 'D:aysb_yiliaousers1 .ORA' SIZE 512M AUTOEXTEND ON maxsize UNLIMITED, 'D:aysb_yiliaousers2 .ORA' SIZE 512M AUTOEXTEND ON maxsize UNLIMITED, 'D:aysb_yiliaousers3 .ORA' SIZE 512M AUTOEXTEND ON maxsize UNLIMITED, 'D:aysb_yiliaousers4 .ORA' SIZE 512M AUTOEXTEND ON maxsize UNLIMITED, 'D:aysb_yiliaousers5 .ORA' SIZE 512M AUTOEXTEND ON maxsize UNLIMITED, 'D:aysb_yiliaousers6 .ORA' SIZE 512M AUTOEXTEND ON maxsize UNLIMITED /*第3步:创建用户并指定表空间 */ create user CXJMYLBX identified by 123456 default tablespace user_data1 temporary tablespace user_temp1; /*第4步:给用户授予权限 */ grant connect,resource,dba to CXJMYLBX;
2.Oracle导入命令:
数据泵导入:
--1.创建逻辑目录,注意此处同时需要手动去该路径下创建该目录,要还原的备份需要放在该目录下 create directory dpdata1 as 'D:appAdministratororadatashengshiguanjudump'; --2.查看管理员目录 select * from dba_directories; --3.给予用户赋予在制定目录下的操作权限 grant read ,write on directory dpdata1 to hnsszjgzfzjglzx; --4.导入数据 impdp hnsszjgzfzjglzx/123456@databasenames directory=dpdata1 dumpfile=system_full_20180426.dmp ignore=y full=y remap_schema=*:hnsszjgzfzjglzx remap_tablespace=*:hnsszjgzfzjglzx
;
逻辑导入:
imp username/password@dataBase file='' log='' ignore=y full=y fromuser= touser=
3.创建Windows Oracle定时备份任务:
创建备份oracle计划任务.bat:
@echo off cd /d "%~dp0" set bat_path=%cd% echo 开始创建计划任务... schtasks /create /tn "Test备份oracle数据" /tr %bat_path%/备份oracle.bat /sc daily /st 22:00:00 /sd 2018/05/02 /NP goto end :end popd pause
备份oracle.bat:
@echo off set curdate=%date:~0,4%%date:~5,2%%date:~8,2% set backuppath=D:backup md %backuppath% exp GADATA0019/orcl@127.0.0.1/ORCL file=%backuppath%%curdate%.dmp owner(GADATA0019) log=%backuppath%%curdate%.log forfiles /p "D:backup" /s /m *.dmp /d -30 /c "cmd /c del @file"