Thursday 6 June 2013

SQL * Plus Copy Utility

Copy tables from one database to another using copy utility.

connect to sql * plus 

command:
copy from scott/oracle@ORCL-
to rajiv/rajiv@ORCL1-
create new_emp1–
using select * from emp;

----------------------------------------
connect to the schema where the table present then  copy the table to another schema  of other Database.

copy to rajiv/rajiv@ORCL1-
create new_emp2–
using select * from emp;
--------------------------------------------------
Description :

The copy command copies data from one Oracle instance to another.   The data is simply copied directly from a source to a target.  The format of the copy command is:

COPY FROM database TO database action -
  destination_table (column_name, column_name...) USING query

The action can include:
 create – If the destination table already exists, copy will report an error, otherwise the table is created and the data is copied. 
replace – If the destination table exists, copy will drop and recreate the table with the newly copied data. Otherwise, it will create the table and populate it with the data. 
insert – If the destination table exists, copy inserts the new rows into the table. Otherwise, copy reports an error and aborts.
append– Inserts the data into the table if it exists, otherwise it will create the table and then insert the data.

Data type Supports: CHAR,DATE,LONG,NUMBER,VARCHAR2 

More Details:

LINK  : http://docs.oracle.com/cd/B19306_01/server.102/b14357/apb.htm

Thursday 21 March 2013

CDB VS PDB [Oracle 12C]


CDB is an acronym for “Container Database” and PDB is an acronym for “Pluggable Database”. I think it will be easier to explain with a metaphor for DBAs. Think of a freight train with many cars up to 250. Each container could be having different contents, with delivery target for different customers and completely packed/sealed independently with customer options but the entire freight is carried by a single engine or carrier at the front. It will be stupid enough to run 250 freight trucks but rather it is efficient to consolidate them into a single freight train. When running independently we will spend on gas, drivers’ expenses and much more complicated to manage them. The freight train is basically the CDB and each car is the PDB.
PDB is fully backward compatible to pre-12.1 database releases. There is nothing different from a developer or application connectivity perspective. Everything stays the same but the PDB will belong to a single CDB. When application connects to the PDB, it will specify the destination PDB via a database service. All home-grown or third party applications typically will have connectivity defined out of the application so it is easier to just change the service name outside of the application code. So all database connectivity should use “database service” rather than using the legacy approach of ORACLE_SID based connectivity. ORACLE_SID ties the application connectivity to a specific database instance and does not give the scalability or high availability. You can have many pluggable databases in 12.1.you can have up to 250 pluggable databases or PDBs within one container database or CDB. It is clear that there is one-to-many relationship between CDB and PDBS.