Restore processing operations for Oracle databases in a hybrid framework

Source: Internet
Author: User

In an earlier essay, "How Oracle implements a one-stop operation for creating databases, backing up databases, and importing data exports" provides a rough overview of backup and restore operations for Oracle databases, and this article wants to introduce scripts or restore operations for Oracle databases based on the development framework.

We have various development frameworks, such as MS SQL Server, Oracle, MySQL, SQLite, PostgreSQL, and so on, in the WinForm development Framework, the hybrid development framework, and the Web development framework, as shown in.

SQL Server supports the most commonly used, but also the most convenient backup restore operations, and Oracle database This is the second and more commonly used database, but compared to SQL Server, Oracle database processing is not so convenient, so this article focuses on the introduction, Based on the framework level of the database, how to implement database script processing or backup file-based restore operations.

1. Database script processing in the framework

If you use database scripting, Oracle can build a table space in the way that Oracle implements a one-stop operation for creating databases, backing up databases, and importing data exports, and then creating the corresponding database information, as shown below.

Create ' C:\app\Administrator\oradata\whcdb\win.dbf ' size 100M; Create User  by default tablespace Win_tbs; Grant  to  Grant to win;

The above code is to create a tablespace file, and then create a win user and append it to the table space.

With this information, we can login to the Oracle database through the user win and the password for win.

Then we can take advantage of this user, on the Plsql table creation and data manipulation processing.

As we create the table, the script looks like this.

/*==============================================================*//*table:tb_city*//*==============================================================*/Create Tabletb_city (ID Number                           not NULL, CityName NVARCHAR2 ( -), ZIPCODE NVARCHAR2 ( -), Provinceid Number,   constraintPk_tb_cityPrimary Key(ID)); Comment on TableTb_city is'National City Table'; Comment on columnTb_city. CityName is'City Name'; Comment on columnTb_city. ZIPCODE is'Postal Code'; Comment on columnTb_city. Provinceid is'Province ID';

For example, if we create different kinds of database scripts, we just need to join in order or choose to execute database script.

So what do you do with these SQL, do you just drag them onto the pl-sql?

Of course not, otherwise a longer database script could lead to very slow execution efficiency.

There are generally two ways to use the command line.

This is done very quickly and is more efficient than executing directly on the Pl-sql SQL window.

Another way to do this is to use another place in the Pl-sql to execute the database script, as shown below.

In the "Tools" import table operation, a dialog box pops up and is one of the most efficient actions to execute the script.

The method described above is to build the corresponding data objects and data according to the database script without the database.

2. Import and Export data using IMP and EXP

Another way to restore existing backup files or to back up existing databases is to use Oracle's command IMP and exp.

Basic format used by IMP: imp[username[/password[@service]]

You can also use IMP in general, and then step-by-step operation.

Let's start by understanding the format of the two commands:

Basic syntax and examples:
1. EXP:
There are three main ways (full, user, table)
1. Complete:
EXP System/manager buffer=64000 file=c:\full. DMP full=y
If you want to perform a full export, you must have special permissions
2. User mode:
EXP sonic/sonic buffer=64000 file=c:\sonic. DMP Owner=sonic
This allows all objects that the user sonic to be exported to a file.
3. Table mode:
EXP sonic/sonic buffer=64000 file=c:\sonic. DMP owner=sonic tables= (SONIC)
This way the user Sonic table Sonic is exported
2. IMP:
Three modes (full, user, table)
1. Complete:
IMP System/manager buffer=64000 file=c:\full. DMP full=y
2. User mode:
IMP sonic/sonic buffer=64000 file=c:\sonic. DMP Fromuser=sonic Touser=sonic
This allows all objects sonic by the user to be imported into the file. You must specify the Fromuser, touser parameter so that data can be imported.
3. Table mode:
EXP sonic/sonic buffer=64000 file=c:\sonic. DMP owner=sonic tables= (SONIC)
This way the user Sonic table Sonic is imported.

Importing the data that a user belongs to also has a user format:

Imp Win/win file=c:\win.dmp Fromuser=win Touser=win

If a table already exists, it will error if executed, and the table will not be imported. Then add ignore=y to the back.

In the framework's database directory, we typically come with the corresponding Oracle backup file (. dmp file) so that users can restore the database directly while developing the Oracle, but if you want to detail each database script, Using Oracle script processing is also one of the best options.

Restore processing operations for Oracle databases in a hybrid framework

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.