Recommendation 1:
The task plan, batch processing file, and Oracle exp export function can automatically generate Oracle backup files based on the date, greatly facilitating ORACLE data backup. :
1. Create a batch file backup. BAT \.
Exp system/manager file = D: \ backup \ oracle % Date :~ 0, 10%. dmp owner = system log = D: \ backup \ oracle % Date :~ 0, 10%. Log
Will generate the oracle2006-01-09.dmp File
Exp system/manager file = D: \ backup \ oracle % Date :~ 11,3%. dmp owner = system log = D: \ backup \ oracle % Date :~ 11,3%. Log
The Oracle Monday. dmp file will be generated, and one backup file will be retained every week. A total of seven backup files will be retained
2. Add a Task Scheduler
Use the task plan Wizard to set the time frequency for automatic task execution (for example, at every day) based on the backup policy, and execute D: \ oracle \ backup. bat
3. backups and log files such as oracle2005-08-31.dmp and oracle2005-08-31.log will be generated in the directory every day.
Note:
1. The value of % date % may be different in different system and language versions. The setting of the region options in the control panel also changes the value of % date %. Test the return value of ECHO % date % in the command line. % Date :~ 4,10% is the return date function ,~ The first parameter is the starting position (starting from 0) to be intercepted, and the second parameter is the length to be intercepted. If not, it is truncated to the end. The parameter can be modified as appropriate.
2. If you need accurate time as the file name, use the % time % function. The parameters are the same as above.
Recommendation 2:
@ Echo off
Set filename = E: \ data_bak \ % Date :~
Exp userid = user/pass @ esdata file = % filename %. dmp owner = user indexes = y grants = y constraints = y compress = y log = % filename %. Log
RAR a folder filename=.rar % filename % .*
Del % filename %. dmp
Del % filename %. Log
Scheduled execution in a scheduled task,
The file name is named in the day part of the date.
Call RAR for compression after backup
This saves the historical data of a month.
Note: Copy rar.exe under the program files/winrardirectory to the System32 directory.
If the name is week, set filename = E: \ data_bak \ % Date :~ Change
Set filename = E: \ data_bak \ % Date :~ 0, 3%
Recommendation 3:
The following is the content of the Oracle automatic backup batch file. Please implement it with the task plan
@ Echo off
Set backpath = D :\
Echo prepare backup database
Rem 7-day cycle
If exist % backpath % \ one goto one
If exist % backpath % \ Two goto two
If exist % backpath % \ three goto three
If exist % backpath % \ Four goto four
If exist % backpath % \ five goto five
If exist % backpath % \ Six goto six
If exist % backpath % \ seven goto seven
Echo E> % backpath % \ one
: One
Set backpath_full = % backpath % \ one
Ren % backpath % \ one two
Goto back
: Two
Set backpath_full = % backpath % \ Two
Ren % backpath % \ two three
Goto back
: Three
Set backpath_full = % backpath % \ three
Ren % backpath % \ three four
Goto back
: Four
Set backpath_full = % backpath % \ Four
Ren % backpath % \ Four Five
Goto back
: Five
Set backpath_full = % backpath % \ five
Ren % backpath % \ five six
Goto back
: Six
Set backpath_full = % backpath % \ Six
Ren % backpath % \ Six Seven
Goto back
: Seven
Set backpath_full = % backpath % \ seven
Ren % backpath % \ seven one
Goto back
: Back
Exp testuser/test file = % backpath_full %. dmp
Set backpath =
Set backpath_full =
Exit
Recommendation 4:
RMAN target = RMAN/RMAN @ orcl <c: \ RMAN. txt
Recommendation 5:
Edit the CMD command in the text. Save the file as a bat file. Define a task plan in windows
It can be automatically executed.
Example:
Edit a text file
Del c: \ exp \ *. dmp
Exp userid = CW/CW @ dB file = 'C: \ exp \ *. dmp 'tables = (student)
Save as a bat file
Recommendation 6:
Write a simple batch file backup and recovery:
Backup:
@ Echo off command line not displayed
Echo starts to back up the table... print the information
D: DOS switch to D: Disk
Switch CD oracle \ ora92 \ bin to the CD oracle \ ora92 \ bin directory
Exp username/password @ database file = D: \ config_bak.dmp tables = (Table1, table2) backup Table 1 Table 2 to D: \ config_bak.dmp
Echo backup complete!
Recovery:
@ Echo off
Echo starts to restore the table .....
D:
CD oracle \ ora92 \ bin
IMP username/password @ database file = D: \ config_bak.dmp tables = (Table1, table2) Ignore = y
Sqlplus/nolog @ orastartup. SQL> orastartup. log calls the SQL File
Pause is paused after the SQL file is executed. view the information.
Echo recovered!
Write orastartup. SQL
Conn username/password @ database as sysdba
Select * From Table1;
Quit;
Execution environment: it can be executed in sqlplus. EXE or DoS (command line,
When dos can be executed, the \ ora81 \ bin installation directory in Oracle 8i is set to a global path,
The exp. EXE and imp. EXE files in this directory are used for import and export.
Oracle is written in Java. I think the sqlplus. EXE, exp. EXE, and imp. EXE files are packaged class files.
Sqlplus. EXE calls exp. EXE and imp. EXE to complete the import and export functions.
The following describes the Import and Export instances. You can import and export instances to the Import and Export instances, because the import and export operations are very simple.
Data export:
1. Export the database test completely, and the username System Password Manager is exported to D: \ daochu. dmp.
Exp system/manager @ test file = D: \ daochu. dmp full = y
2. Export the tables of system users and SYS users in the database
Exp system/manager @ test file = D: \ daochu. dmp owner = (system, sys)
3. Export tables Table1 and Table2 in the database
Exp system/manager @ test file = D: \ daochu. dmp tables = (Table1, table2)
4. Export the data with the field filed1 in table 1 in the database starting with "00"
Exp system/manager @ test file = D: \ daochu. dmp tables = (Table1) query = \ "where filed1 like '201312 '\"
The above is a commonly used export. I am not very concerned about compression. I can use WinZip to compress the DMP file.
However, add compress = Y to the command above.
Data Import
1. import data from D: \ daochu. dmp to the test database.
IMP system/manager @ test file = D: \ daochu. dmp
The above may be a problem, because some tables already exist, and then it will report an error, the table will not be imported.
Add ignore = Y to the end.
2. Import table 1 in D: \ daochu. dmp
IMP system/manager @ test file = D: \ daochu. dmp tables = (Table1)
Import
The preceding import and export operations are sufficient. In many cases, I completely delete the table and then import it.