November 28, 2010

Lock a table

Locking a table prevents two users to update a table at same time. 
Using locks we can prevent data replications. 
 
LOCK TABLE employees
   IN EXCLUSIVE MODE;
This exclusive mode enables the user to look into the rows but can update it.
And this command for remote link tables.
LOCK TABLE employees@DB
IN SHARE MODE 
 
The alternative for this is to use sequence in your table.It will also prevent data duplications. 

Index

Indexing...


why we should go for indexing?


When we are using more then two tables with 'n' number of check with DB.
We can create index for the specific column name to be referenced.


e.g:


create

So now when i run the query in my package it will refer to the index in the ratio 1:1:1:1

i.e everything join conditionally.

This will reduce the time consumption also.
index ix_index on per_all_people_f(person_id,effective_end_date,person_type_id,national_identifier);

COALESCE-SQL

Coalesce- return the null values from the expression. It works similar to a case statement where if expression 1 is false then goes to expr...