Sunday, September 4, 2016

How to create PARFILE and How to use it.

How to create PARFILE and How to use it.
PARFILE is a simple text file also called it parameter file, which is used by the expdp utility. It means PARFILE can be created by client (database user) on his own system, and in that case no need to involve the DBA whereas files like DUMPFILE and LOGFILE are the files which are created by the expdp utility on the server.

And also with the creation of PARFILE, client (Database User) can also modify and update the PARFILE as per the requirements.
Location for the PARFILE:-
The Database user can create a PARFILE anywhere on its own system.
How to set name of PARFILE?
In the ORACLE DATABASE there is no restrictions for the name of PARFILE. You can give any name what you want to give to parfile, and about extension, same like logfile and dumpfile you can give whatever extension what you want for the PARFILE.
But we recommend to give (.par) extension, it will be helping us to identified the PARFILE from other files in your system.

Contents for the PARFILE?
The PARFILE contains the parameters which is used by the expdp utility like,
  1. Directory name.
  2. Dumpfile name.
  3. Logfile name.
  4. Schemas name (if you want to perform the schemas export).
  5. Tablespace name ( if you want to perform exporting tablespace).
  6. Full (if you want to perform full database export).
How to create PARFILE
STEP-1
Firstly we need to create a folder on any location in your system, so before doing anything you just make a folder and give a logical name to this directory then make a directory, following steps.
As in this tutorial I’m going to use a folder which is name is ‘table_exp’ and the folder location is:
$mkdir /u01/table_exp
Step 2: Now create Directory object.
So for the creating directory object we need to login as SYS user with SYSDBA privileges.
$sqlplus / as sysdba
SQL> create directory tables_exp as ‘/u01/table_exp’;
Above command will create the directory objects.
Now after create the directory we need to grant some mandatory privileges to those users who wants to perform the export.
Like SCOTT and SYSTEM users wants to perform export.
SQL> grant read, write on directory tables_exp to scott,system;

STEP 3. CREATE A PARFILE.
Just create a plain text file (notepad file) in any location in your system, for demonstration I have created a file in “/u01/exp_scott.par” directory.
After making the text file we have need to write all the necessary parameters in this file.
Directory= tables_exp
Dumpfile=table_scott.dmp
Logfile=table_scott.log
Tables=emp,dept,jobhistory
After making this file we need to run expdp utility, using following command.
$expdp scott/tiger@db11g parfile=’/u01/ exp_scott.par’
This command is automatically take an export backup of those tables which we write in the parfile.

NOTE: – The PARFILE cannot be specified within a parameter file and also you cannot write login information of the database in parameter file.

No comments:

Post a Comment