Showing posts with label Unix. Show all posts
Showing posts with label Unix. Show all posts

December 20, 2016

How to Export or Import oracle database

Oracle database is providing some command line tools to import or export any schema , data of a schema or the total oracle database from one to another. These tools come along with the oracle database installation by default.

Exporting:
There are two command tools to export database exp and expdp.

exp command:
Open the console and give the exp command on the command prompt. It will prompt for information like username, password, export filename and path etc as below.

Example of using oracle database command "exp"

And also it will show few options like below. You can export entire database or only users/schemas or only the tables. You can also mention, whether you want to export permission and data inside the tables also.


 After providing all these information, it will start exporting the database. After finishing it you can observe a statement like "Export terminated successfully"


Instead of following the above step by step procedure, we can give all this in a single command which will do the same. Below is the example of the command.

Ex:  Exp userid=mytestings/welcome1@xe file=d:\mydump.dmp



expdp command:
Another tool to export database is expdp command. Which works like exp command but it is more powerful. Below is the example to use this command.

expdp mytestings/welcome1 dumpfile=mydump_1.dmp logfile=mydump.log


Importing:
There are two command tools to import database from the .dmp files are imp and impdp.
These two works like the above export commands.

Below are the syntax and example to use imp command.
Syntax:
imp userid/password@Connect_identifier fromuser=user_name_you_have_data_unloaded_from touser=new_user_name file=Path_to_*.dmp file

Ex: imp testuser/welcome1@xe fromuser=mytestings touser=testuser file=D:\Data\MYDUMP.dmp

The result would look like as below.


Below is the example to use impdp command.

impdp mytestings/welcome1@orcl TABLE_EXISTS_ACTION=REPLACE dumpfile=MYDUMP.dmp

Instead of passing options to the command line, we can create a .par file and give all these properties in that file and pass that file to the command as below. This .par file option is available for both impdp and expdp commands but not imp and exp commands.

impdp sccinternal/welcome1@orcl parfile=impdata.par

Sample .par file look like as below.

schemas=mytestings
logfile=importlog.log
dumpfile=MYDUMP.dmp
TABLE_EXISTS_ACTION=REPLACE




October 26, 2014

How to connect remote machine in Unix

Below command is useful to connect remote machine or server in Unix.

SSH <user>@<host name>

Example:

SSH anand@mymachine

October 10, 2014

How to make an entry of host file in Unix

Below is the procedure to make an entry of host file in Unix

  • Open host file: /etc/hosts
  • Make an entry to the file like below
           <ip> <hostname>
           Ex:
             10.143.121.118  myhostname
  • Save the file
  • And run below command to flush the DNS cache
           dscacheutil -flushcache

October 18, 2012

Unix commands to shutdown/restart


The below commands are very useful especially when we are working with Unix Consoles or VMs with Unix OS, to power off them properly.

To Shutdown:  /etc/halt -p
To Restart: /sbin/reboot