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.