Oracle database backup and recovery script sorting

Source: Internet
Author: User

1: create a user
Copy codeThe Code is as follows:
Create temporary tablespace user_temp
Tempfile 'd: \ app \ topwqp \ oradata \ orcl \ user_temp.dbf'
Size 500 m
Autoextend on
Next 50 m maxsize 2048 m
Extent management local;
Create tablespace ts_mydb
Logging
Datafile 'd: \ app \ topwqp \ oradata \ orcl \ ts_mydb.dbf'
Size 500 m
Autoextend on
Next 50 m maxsize 2048 m
Extent management local;
Drop user mydb cascade;
Create user mydb identified by mydb
Default tablespace ts_mydb
Temporary tablespace user_temp;
Grant connect, resource, dba to mydb;

Significance of the preceding commands:
Create a temporary tablespace. The temporary file name is the file actually stored in oracle. size indicates the size of the tablespace, and autoextend indicates the extended size when the capacity is full.
Before creating a user, cascade and delete user information,
Create the user name and password, and then authorize the user. The connect, resource, and dba permissions are granted here, and detailed authorization is required to re-query the information.
2. Import the database
Copy codeThe Code is as follows:
Set userid = mydb/mydb @ orcl
Set fromuser = test
Set touser = mydb
Sets FILENAME = test_bak2013-03-22.dmp
Set logname = mylog. log
Imp % USERID % file = % FILENAME % fromuser = % FROMUSER % touser = % TOUSER % log = % LOGNAME %

Userid is used to import the username/password of the database to be imported and the database name,
FROMUSER refers to the User Name of the backup database, TOUSER is used for the user in the database to be imported, and FILENAME is used to specify the backup dmp database file required for import.

LOGNAME indicates the log file. Note that the imported database must be in the same location as the script.
Usage: copy the above Code and save it to The. bat file. Then double-click it to execute it.
3: export the database
Copy codeThe Code is as follows:
Set curdate = % date :~ 0, 10%
Set userid = test/test @ orcl
Set owner = test
Set filename = test_bak % CURDATE %. dmp
Set logname = test_bak % CURDATE %. log
Exp % USERID % file = % FILENAME % owner = % OWNER % log = % LOGNAME %

Here, userid is the username and password for import, curdate is used to obtain the current date, OWNER is used to indicate which user to export, FILENAME is the exported file name, and LOGNAME is the exported log file,
Then run the Export command.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.