Thursday, February 26, 2015

how to Processing SQL in Oracle

The following steps show how Oracle processes SQL
1. Statement is passed to Oracle for processing
2. Before it is placed in the library cache, a hash value is computed that
represent s a number of characteristics of the SQL.
3. Oracle compares the computed hash value against those values in a hash
table where it maintains for SQL statements already in the cache.
4. If a match is found, the new SQL statement is thrown away and the one
sitting in the cache is executed on its behalf.
5. In no match is found, further processing is done on the new SQL
statement, an entry is made in the library cache hash table for newly
arrived code, and it is placed in the library cache.
6. There are 3 stages of SQL processing – parse, execute and fetch
· During parsing, Oracle server checks the syntax and validates
table, column names against data dictionary
· Determines whether user has privilege to execute the statement
· Determines optimal execution plans for statement
· Finds a shared SQL area for the statement
· In execution stage, for UPDATE and DELETE statement, Oracle
locks the affected rows, looks for data blocks in DB buffer cache,
if found, executes becomes faster, if not then Oracle has to read
from physical data files to buffer cache. For SELECT and INSERT
statements, locking is not necessary.
· During fetch operation, rows are fetched to user process.

Background processes in oracle

Database Writer (DBWn)
:It is responsible to redo log buffer management. Almost all activities against the database are tracked in the online redo logs. As transaction are initiated and
eventually committed or rolled back, a record of this activity is written to these
log files.

Checkpoint (CKPT):
A checkpoint is an event that flushes modified data from buffer cache to disk and updates control file and data files. The CKPT process updates header of data files and control files and
DBWn writes actual blocks to file. Checkpoint occurs automatically when an
online redo log file fills (log switch).

System Monitor (SMON):
At startup, SMON’s job is to ensure that all the database files are consistent and
perform recovery if required. There is also an assortment of other cleanup
activities that may need to be done, which are SMON’s responsibility. The
SMON process by itself checks every so often to see whether there are any tasks
waiting for its attention.

Process Monitor (PMON):
Cleans up failed user processes and frees all resources used by failed process.

Archiver (ARCn):
It automatically saves copies of redo logs in a DBA specified storage location
when media recovery is enabled.

Recover (RECO):
Is used with distributed transaction to resolve failure.

Saturday, February 21, 2015

Steps to Configure database in archive log mode in oracle


 SQL> select NAME,LOG_MODE from v$database;

  NAME      LOG_MODE
   ———       ————
    ORCL      NOARCHIVELOG

SQL> shutdown immediate;
 Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount
ORACLE instance started.

Total System Global Area  535662592 bytes
Fixed Size                  1375792 bytes
Variable Size             281018832 bytes
Database Buffers          247463936 bytes
Redo Buffers                5804032 bytes
Database mounted.

SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     15
Next log sequence to archive   17
Current log sequence           17
SQL> select name,log_mode from V$database;

NAME      LOG_MODE
--------- ------------
ORCL      ARCHIVELOG



database is configured in archive log mode.





 

Monday, February 2, 2015

What are the types of SQL statement in Oracle .



Data Definition Language: CREATE, ALTER, DROP, TRUNCATE, REVOKE, NO AUDIT & COMMIT.
Data Manipulation Language: INSERT, UPDATE, DELETE, LOCK TABLE, EXPLAIN PLAN & SELECT.
Transactional Control: COMMIT & ROLLBACK
Session Control: ALTERSESSION & SET ROLE
System Control: ALTER SYSTEM.

How to Increase Import Size Limit in phpMyAdmin



 modified the  php.ini.

upload_max_filesize = 2M  to
 
upload_max_filesize = 200M 

Wednesday, January 21, 2015

Which user executing what type of command in oracle

SELECT SID,SERIAL#,v.schemaname,
DECODE(COMMAND,0,'None',2,'Insert',3,'Select',6,'Update',7,'Delete',8,'Drop',26,'Lock Table'
,44,'Commit',45,'Rollback',47,'PL/SQL Execute','Other') command FROM V$SESSION v


       SID    SERIAL# SCHEMANAME                     COMMAND     
---------- ---------- ------------------------------ --------------
         1          1 SYS                            None          
         2          1 SYS                            None          
         3          1 SYS                            None          
         4          1 SYS                            None          
         5          7 SYS                            None          
         8          1 SYS                            None          
         9         10 SYS                            None          
        63          5 SYS                            None          
        64          1 SYS                            None          
        65          1 SYS                            None          
        66          1 SYS                            None          
        69         52 SYS                            None          
        70          3 SYS                            None          
        72        485 SYS                            None          
       125          1 SYS                            None          
       126          1 SYS                            None          
       127          1 SYS                            None          
       128          1 SYS                            None          
       129          3 SYS                            None          
       131        631 DRSTR                    Select        
       132        448 SYSTEM                  Select        
       187          1 SYS                            None          
       188          1 SYS                            None          
       189          1 SYS                            None          
       190          1 SYS                            None          
       192          4 SYS                            None          
       194          1 SYS                            None          
       195          1 SYS                            None          
       199         27 SYS                            None          

 29 rows selected

Tuesday, January 13, 2015

snapshot too old error: ORA:01555

You get this error when you get a snapshot too old within rollback. It can usually be solved by increasing the undo retention or increasing the size of rollbacks. You should also look at the logic involved in the application getting the error message.