oracle database client open, create, export, import

1, install the oracle client

Modify the configuration file



As follows, we need to be modified


# tnsnames.ora Network Configuration File: F:\oracle11g\product\11.1.0\db_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.




paddb =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.74)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = paddb)
    )
  )
sqdb =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.174)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = sqdb)
    )
  )
sqdb =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )


The default configuration will show three names paddb, sqdb, sqdb


We need to create a user name and password authorization database




SQL * Plus: Release 11.2.0.1.0 Production on 2014 09:49:03 Saturday, November 8


. Copyright (c) 1982, 2010, the Oracle All Rights Reserved.


SQL> conn SQAPP / SQAPP
connected.
SQL> Show the Tables;
SP2-0158: Unknown SHOW option "the Tables"
SQL> IDENTIFIED by the Create the User chenjianpeng 123456;


the user has created.


SQL> Grant the session to chenjianpeng;
Grant the session to chenjianpeng
      *
Line 1 error:
ORA-01919: role 'SESSION' does not exist




SQL> grant dba to chenjianpeng;


authorization is successful.


SQL>


Oracle in data objects and data management, no doubt using PL / SQL Developer to manage the tools available to us a lot of convenient and efficient operation, so that we no longer Oracle itself ugly, difficult to use UI complain . Since we are generally built in built form, look up operational data of the majority, less likely to consider the entire Oracle's complete system backup operations. But in some of our publishing operations, we must consider how to export Oracle objects, table data to Sql script and to create Oracle table space, create the Oracle database operations also put the script, so that we facilitate the rapid reduction or deploying Oracle database to a new machine.

This article describes how to combine Sql scripts and PL / SQL Developer tools to create a table space, create a database, database backup, data export and other operations, and then implement Oracle object creation, import data and other operations, help us to quickly understand, create the required deploy Sql script and database operations.

1, to prepare the database creation script

create  tablespace whc_tbs datafile 'E:\oracle\oradata\whcdb\whc.dbf'  size  100M;
--DROP TABLESPACE whc_tbs INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS;
create  user  whc identified by  whc default  tablespace whc_tbs;
 
grant  connect ,resource to  whc;
grant  dba to  whc;
--Revoke dba from whc;

Which - comment statement is to remove the namespace and remove the DBA user permissions.

These scripts are for our use in a new Oracle database table space and time.

Where E: \ oracle \ oradata \ whcdb \ whc.dbf path is the position we want to store data in the database, so make sure the path there is enough space and enough access rights, otherwise it will fail.

 

2, export database objects

In the menu Tools PL / SQL Developer's => Export User Objects out of a dialog interface, then marquee Oracle database objects to be everywhere, including tables, sequences, stored procedures, views, functions, etc., and specify the name of the exported file , as follows.

 

3) deriving table data

 After you export the table structure and other objects, our next step is to export data from a database table, PL / SQL Developer tool supports exporting data to a PL / SQL database script, as shown below. Such export script, we can import in PL / SQL Developer tool or import your own by Sql plus tools.

至此,我们就已经完成了三种脚本了,包括创建数据库空间和数据库脚本、创建Oracle数据库对象(表、存储过程、视图、序列等)、创建导入数据的脚本,这样三种合一,就是一个完整的数据库了。最后一步就是我们如何导入数据库对象和数据的问题了。

 

4)导入数据库对象及数据

导入数据库对象和数据的操作一样,都可以通过Import Tables操作实现,我们指定刚才上面两步创建的数据库脚本,执行即可再新的环境中创建数据库对象和数据库数据了。如下所示。

执行的数据界面如下所示。

完成上面几个步骤,我们在新的数据库环境中,就具备了所有的东西了,顺利完成整个Oracle数据库对象及数据的迁移工作。

以上值得注意的是,我们导出Oracle对象和数据的时候,默认还是原来Oracle数据库的表空间和数据库用户名称的,如果我们想要在新的数据库服务器中指定不同的表空间和数据库用户对象,那么我们就需要替换生成的sql脚本,并在第一步指定合理的表空间和数据库用户。

如果是Linux平台下的数据库服务器,第一步操作也是差不多的,就是指定表空间的路径名稍微不同,其他操作并无差异。




Guess you like

Origin blog.csdn.net/jianpengxuexikaifa/article/details/40918195