The Automatic Import and Export of Oracle databases are widely used in many places. for example, after an Oracle database application system is developed, if you want to install the system on your computer, you need to import the initial data to your Oracle database.
The above functions need to be implemented in recent projects. It takes some time to search for the experiment and sort it out as follows: First, export the initial data file to be installed as initial. DMP, then install oracle on the customer's computing, and then execute the batch processing file impinitialdata. BAT (the same directory as the batch processing file also has createuser. SQL, initial. two DMP files) impinitialdata. the content in bat is as follows:
@ 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 the SQL extension. It is placed in the same directory as the batch file. Its content is:
Create user initialuser
Identified by test;
Grant dBA, resource, connect to initialuser;
Exit; briefly explained:
@ Echo off
The subsequent commands are not displayed in the Command Prompt window.
Sqlplus is an oracle Tool Program You must install Oracle before using it.
System/Manager
It is a default Administrator Account of Oracle. If the account is locked or the password is changed, it cannot be used. You can replace it with another account/password;
@ Createuser: Execute the createuser. SQL file.
In this SQL file, create user xx
Identified by YY; indicates creating a user XX whose password is YY;
Grant dBA, resource, connect to xx; indicates authorizing the user xx
The dBA, resource, and connect permission imp are the import data command. In the following parameters, file indicates the database file to be imported; fromuser indicates the username of the original exported database file; touser indicates the username of the database to be imported. Ignore indicates that the general method for ignoring errors is as follows. You can add other commands to perform more complex operations.