Database Instance


A database instance contains a collection of memory structures and Oracle Database background processes.

  • The main memory structures are the System Global Area (SGA) and the Program Global Areas (PGAs).
  • The background processes operate on the stored data (data files) in the database and use the memory structures to do their work.
A database instance exists only in memory.


Oracle Database also creates server processes to handle the connections to the database on behalf of client programs, and to perform the work for the client programs.
For example, parsing and running SQL statements, and retrieving and returning results to the client programs.
These types of server processes are also referred to as foreground processes.



Oracle Database Server

An Oracle Database consists of at least one database instance and one database.

  • The database instance handles memory and processes.
  • The database consists of physical files called data files and several database system files.

The listener is a database server process. It receives client requests, establishes a connection to the database instance, and then hands over the client connection to the server process.

How to find the sid of oracle database?

General Database Questions
Following are the different ways to find the SID of ORACLE database.

1. Without connecting to database 

WINDOWS:

If Environment Variables are set, then use below command in windows command prompt.

echo %ORACLE_SID%

If Environment Variables are not set, then you can check the window's service for a service named OracleService<sid_name>. 

UNIX/LINUX:

If Environment Variables are set, then use below command in command line.

echo $ORACLE_SID

If Environment Variables are not set, then you can check the /var/opt/oracle/oratab file on UNIX and the /etc/oratab file on LINUX.

2. After connecting to database

Connect with SYS or SYSTEM user. Execute any following SQL statement to find the ORACLE_SID
  • SHOW PARAMETER INSTANCE_NAME 
  • SELECT INSTANCE FROM V$THREAD; 
  • SELECT SYS_CONTEXT('USERENV','INSTANCE_NAME') FROM DUAL; 
Find the sid of oracle database
How to find the sid of oracle database









ORA-01704: string literal too long


What is the cause of the ORA-01704: string literal too long ?
or
How to insert records length larger than 4000 into CLOB columns?

Cause:
The string literal is longer than 4000 characters.
Action:
Use a string literal of at most 4000 characters.
Longer values may only be entered using bind variables.

Below are the required steps in order to regenerate the use case:-

1. Create a dummy table:-

create table test_clob (mtype varchar2(20),dummy_clob clob);


2. Try to insert a text having length greater than 4000.

insert into test_clob values ('try1','This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text;');


Error:- ORA-01704: string literal too long

Solution:-

Following are the two solutions:-

1.In SQL there is a limit of 4000 character to a varchar2.
And anything enclosed in single quotes is by default, treated as a varchar2.

Break your text into 4000 character blocks and enclose each chunk with function TO_CLOB(...), and concatenate these clobs.
Below is the example for the same.

insert into test_clob values ('Solution1',
to_clob('This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; ') || 
to_clob(' This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text;'));


2. By using PL/SQL, assign the large text to a clob variable & use this variable to insert the data.

DECLARE
    large_txt CLOB;
BEGIN
    large_txt:='This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text; This is a very large text;';
    insert into test_clob
    values      ('Solution2',
                 large_txt);
END;




Hope this article will help you out in order to solve the error ORA-01704: string literal too long.

Types of RMAN Backup


Full backup: A full backup backs up all data files in the database, block-by-block, a standalone backup with everything you need to recover to the point in time when the full backup was collected.
Incremental backup: An incremental backup can be either level 0 or level 1.

Incremental backup levels

Level 0 backup: A level 0 incremental backup is physically identical to a full backup and it includes every data block in the file except empty blocks. The only difference is that the level 0 backup is recorded as an incremental backup in the RMAN repository, so it can be used as the parent for a level 1 backup.
Level 1 backup: A level 1 backup includes only those blocks that have been changed since the "parent" backup was taken. Remember a parent backup may be either a level 0 or a level 1 backup.

Two types of incremental backup

Differential incremental backup:- which backs up all blocks changed after the most recent incremental backup at level 1 or 0
Cumulative incremental backup:- which backs up all blocks changed after the most recent incremental backup at level 0

How to detect Spatial feature usage?


By using all_sdo_geom_metadata view.

column spatial format a10;
SELECT DECODE(COUNT(*), 0, 'No', 'Yes') Spatial
FROM
  ( SELECT 1 FROM all_sdo_geom_metadata WHERE rownum = 1
  );

Sample Output:-

how to enable or disable oracle database features?


chopt tool a command-line utility is used for enabling or disabling a particular database feature for an Oracle home.

Location:- ORACLE_HOME\bin directory

Syntax:- chopt [ enable | disable] <option>

options:
dm = Oracle Data Mining RDBMS Files
olap = Oracle OLAP
partitioning = Oracle Partitioning
rat = Oracle Real Application Testing
ode_net = Oracle Database Extensions for .NET

Example of running the chopt tool:-

chopt enable dm
chopt disable dm

Sample output:-

How to check whether Oracle Management Pack access is available or not?


Following are the two ways to check Management Pack access is available or not:-

1. By using v$parameter

column name format a35;
column value format a35;
SELECT name,value FROM v$parameter WHERE name LIKE '%pack%';

Sample output:-



2. By using CONTROL_MANAGEMENT_PACK_ACCESS parameter

show parameter CONTROL_MANAGEMENT_PACK_ACCESS;

Sample output:-

How to detect Active Data Guard feature usage?

By using v$managed_standby view:-

SELECT 'Using Active Data Guard' ADG
FROM v$managed_standby m,
  v$database d
WHERE m.process LIKE 'MRP%';


Sample Output:-