Skip to main content

Connect to an Oracle Database on Unix Environment

Below are the steps to connect to an Oracle database. These can be helpful to the people who are new to the Oracle world.

1. Login to unix user which has the permissions to connect to database. Most of the times it is with the name Oracle but it may vary from one installation to other. This unix user is part of the dba group for administrator actions and oinstall group to manage the software (install, software patching etc.).

2. Ensure your environment variables are set properly. Below are the environment variables and their description that should be set:

ORACLE_HOME - Location to the Oracle database software.
ORACLE_SID - Name of the Oracle Instance to connect. Database name can be different that of the instance. This is the case in ORACLE RAC environment.
PATH - PATH environment should be modified to also include the location of Oracle binaries like sqlplus, lsnrctl etc.

For example if your database name is TEST and location of the Oracle software is /home/oracle/product/11.2.0.2/

export ORACLE_SID=TEST
export ORACLE_HOME=/home/oracle/product/11.2.0.2/
export PATH=$PATH:$ORACLE_HOME/bin

In order to permanently store the settings of above variables, it is recommended to save these in profile file of the user.

3. Running Oracle instances on a server can be identified using "ps" command in unix. (ps -ef | grep pmon)

4. login to sqlplus with sysdba privileges. - on unix command prompt type: sqlplus / as sysdba

5. Check the database details. On SQL prompt type the below query:

select name,open_mode from v$database;
Startup a database if it is down.

Connect to sqlplus as sysdba.
SQL>startup

Shutdown the Oracle database. - DO NOT USE THIS COMMAND UNTIL NOT REQUIRED. THIS IS ALWAYS DONE DURING PLANNED MAINTENANCE WINDOWS. ALWAYS INFORM USERS ABOUT THE DOWNTIME.

Connect to sqlplus as sysdba.
SQL>shutdown

Comments

Popular posts from this blog

Configure Oracle ASM Disks on AIX

Configure Oracle ASM Disks on AIX You can use below steps to configure the new disks for ASM after the raw disks are added to your AIX server by your System/Infrastructure team experts: # /usr/sbin/lsdev -Cc disk The output from this command is similar to the following: hdisk9 Available 02-T1-01 PURE MPIO Drive (Fibre) hdisk10 Available 02-T1-01 PURE MPIO Drive (Fibre) If the new disks are not listed as available, then use the below command to configure the new disks. # /usr/sbin/cfgmgr Enter the following command to identify the device names for the physical disks that you want to use: # /usr/sbin/lspv | grep -i none This command displays information similar to the following for each disk that is not configured in a volume group: hdisk9     0000014652369872   None In the above example hdisk9 is the device name and  0000014652369872  is the physical volume ID (PVID). The disks that you want to use may have a PVID, but they must not belong to a volu...

Adding New Disks to Existing ASM Disk Group

Add Disks to Existing ASM Disk Group In this blog I will show how to add new disks to an existing ASM Disk group. This also contains the steps to perform the migration from existing to the new storage system. In order to add the disk to the ASM disk group, you will first need to configure these disk using the operating system commands. I have provided the steps to configure the disks on AIX system in my blog " Configure Oracle ASM Disks on AIX" Adding New Disks to DATA Disk Group (Storage Migration for DATA Disk Group) Login to your ASM instance $ sqlplus / as sysasm If the name of the new disk is in different format from the existing disk, the modify the asm_diskstring parameter to identify the new disks. In my below example /dev/ora_data* is the format of the existing disks and /dev/new_disk* is the naming format of the newly configured disks. You should not modify this parameter unless the naming format changes. SQL> alter system set asm_diskstring = '/dev/ora_data*...

Load records from csv file in S3 file to RDS MySQL database using AWS Data Pipeline

 In this post we will see how to create a data pipeline in AWS which picks data from S3 csv file and inserts records in RDS MySQL table.  I am using below csv file which contains a list of passengers. CSV Data stored in the file Passenger.csv Upload Passenger.csv file to S3 bucket using AWS ClI In below screenshot I am connecting the RDS MySQL instance I have created in AWS and the definition of the table that I have created in the database testdb. Once we have uploaded the csv file we will create the data pipeline. There are 2 ways to create the pipeline.  Using "Import Definition" option under AWS console.                    We can use import definition option while creating the new pipeline. This would need a json file which contains the definition of the pipeline in the json format. You can use my Github link below to download the JSON definition: JSON Definition to create the Data Pipeline Using "Edit Architect" ...