The automatic import and export of Oracle database has been widely used in many places. For example, once an Oracle database application system is developed, it is necessary to import the initial data into the user's Oracle database if the system is to be installed on the client computer.
Recent projects also need to implement the above features, spent some time searching for experiments, sorted as follows: First, the initial data file to be installed to INITIAL.DMP, and then install Oracle on customer calculation, and then execute batch file Impinitialdata.bat ( The same directory as the batch file and createuser.sql,initial.dmp two files) Impinitialdata.bat the following:
@echo off
Sqlplus System/manager @createuser
Imp System/manager file=initial.dmp fromuser=initialuser touser=initialuser ignore = y
The createuser above is a file with an extension of SQL. In the same directory as the batch file. Its contents are:
Create user initialuser identified by test;
Grant Dba,resource,connect to Initialuser;
Exit
Add: Drop user POWERCC cascade; Where POWERCC is the user name.
Briefly explain:
@echo off indicates that the command after it is not displayed in the Command Prompt window
Sqlplus is a tool for Oracle, you must install Oracle before you can use
System/manager is a default administrator account for Oracle, and can be replaced with another account/password if the password is locked or changed;
@createuser represents the execution of the Createuser.sql file
In the SQL file, create user xx identified by YY, which means creating a password for yy users xx;
Grant Dba,resource,connect to XX; delegate authorization to user xx Dba,resource,connect permissions
IMP for the Import Data command, the following argument file represents the database file to import; Fromuser represents the user name of the original exported database file; Touser represents the user name of the database to be imported; ignore means to ignore errors. Additional commands can be added to perform more complex operations.