Create backup and recovery scripts for Oracle databases

Source: Internet
Author: User
1: create a user:

 

 
Create temporary tablespace user_temptempfile 'd: \ app \ topwqp \ oradata \ orcl \ user_temp.dbf 'size 500 m autoextend onnext 50 m maxsize 2048 mextent management local; Create tablespace ts_mydbloggingdatafile 'd: \ app \ topwqp \ oradata \ orcl \ comment 'size 500 mautoextend onnext 50 m maxsize 2048 Mexican management local; drop user mydb cascade; create user mydb identified by mydbdefault tablespace ts_mydbtemporary tablespace user_temp; grant connect, resource, DBA to mydb;

The preceding command indicates:

 

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

Set userid = mydb/mydb @ orclset fromuser = testset touser = mydbset filename = test_bak2013-03-22.dmpSET LOGNAME = mylog. logimp % 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 or aboveCodeSave it to The. BAT file and double-click it.

3: export the database

 

 
Set curdate = % Date :~ 0, 10% set userid = test/test @ orclset owner = testset filename = test_bak % curdate %. dmpset LOGNAME = test_bak % curdate %. logexp % 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.