How to Write a batch file to automatically import data to the Oracle database

Source: Internet
Author: User

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.
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.