Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
6Activity
0 of .
Results for:
No results containing your search query
P. 1
Locks

Locks

Ratings: (0)|Views: 575|Likes:
Published by api-3759101

More info:

Published by: api-3759101 on Oct 15, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

Locks
Locks are used to ensure data integrity while allowing maximum concurrent access to the data by unlimited
users
Types of locks According to the way locks are applied
1. Implicit locking
2. Explicit locking
Implicit locking

This will be done automatically by DBA based on the DDL or DML processed.
Readers of data do not wait for other readers or writers.
Writers of data do not wait for other readers
Writers of data have to wait for other writers if they attempt to update the same rows at
the same time.

Explicit locking
A lock can be put by an operator or trigger is called explicit locking
Oracle provides two levels of automatic locking Table level & row level

There are two ways of locking the table or rows
1. Select \u2026\u2026\u2026for update (row level locking)
2. Lock table statement (table level locking)

1. Select \u2026 for update

Can not be used with distinct and group by clause
Can not be used with set operators and group functions
Row level locking.

2 Lock table statement
Table level locking
Lock table table_name in share/share update/exclusive mode;
Share lock

Locks the table allowing other users to only query but not insert, update
or delete rows in table
Multiple users can place share locks on the same table at the same time

Share update lock

Locks the only rows that are effected.
Allowing other users to query, insert, update, delete or even lock the
other rows in table

Exclusive lock

Same as share lock but only one user can place this lock mode on the table at a time. Where as share lock can be placed, by many users on same table

If the rows or table , are already locked by another user, then Oracle will wait for
the lock to be released by a commit or rollback statements. How ever we can use
NOWAIT option to cause Oracle to terminate the statement.
A rollback to save point releases all locks acquired, up to the named save point
are released

1
Functions
Functions are a very powerful feature of SQL and can be used to do the following:
\ue000
Perform calculations on data
\ue000
Modify individual data items
\ue000
Manipulate output for groups of rows
\ue000
Format dates and numbers for display
\ue000
Convert column datatypes
SQL functions may accept arguments and always return a value.
Types of functions
\u2022
Character
\u2022
Number
\u2022
Date
\u2022
Conversion
\u2022
Function that accept any data type
\u2022
Group or aggregate
Character functions
Chr(n)
It returns the character having the binary equivalent to n in the database
character set.
Chr(67) returns \u2018C\u2019
ASCII(\u2018C\u2019)
It returns the numeric value in the database character set.
ASCII(\u2018C\u2019) returns 67

Lower(Column_name/value)
Upper(Column_name/value)
Initcap(Column_name/value)
Concat(char1,char2)

Lpad(column_name, n,\u2019 string\u2019)
Pads the column or literal value from the left to a total width of n character
positions. The leading space are filled with string
Select lpad(ename,20,\u2019*\u2019)
***************smith
If ename is 10 characters long then 10 * s will be padded at left of the ename
Rpad (column_name, n, \u2019string\u2019)
Pads the column or literal value from the right to a total width of n character
positions. The tailing space are filled with string
Select rpad(ename,20,\u2019*\u2019)
smith***************
If ename is 10 characters long then 10 * s will be padded at right of the ename
Substr(column-name/value,pos,number of characters)
If number of characters are omitted, it returns up to end of the string
Instr(Column_name/value,\u2019string\u2019)
Gives the character Position of the first accurrence of the string in the column or
value.
Select dname ,instr(dname,\u2019A\u2019) from dept;
Dname
instr(dname,\u2019A\u2019)
Accounting
1
Instr(col/value,\u2019string\u2019,pos,n)
Gives the character Position of the first accurrence of the string in the
column or value starting at the pos.
2
Select dname ,instr(dname,\u2019C\u2019,1,2) from dept;
Dname
instr(dname,\u2019c\u2019,1,2)
Accounting
3
LTRIM
Ltrim(Column_name/val)\u2014trims leading spaces
Ltrim(Column_name/val,\u2019char\u2019) \u2013 trims leading specified character in the value
RTRIM
Rtrim(Column_name/val)\u2014trims tailing spaces
Rtrim(Column_name/val,\u2019char\u2019) \u2013 trims tailing specified character in the value
SoundexReturns a character string sound a like

Select ename from emp where Soundex(ename) = \u2018FRED\u2019
Ename
Ford

Length
Returns length of the string in characters.
TranslateTranslate(col/val,\u2019fromchar\u2019,\u2019tochar\u2019)
Used for character substitution
If tochar is omitted, from char will be removed from the column/value
Replace

replace(col/val,\u2019fromstring\u2019,\u2019tostring\u2019)
Used for string substitution
If tostring is omitted, fromstring will be removed from the column/value
Replace is superset of translate

Number functions
Round(col/val,n)

N is the number of positions after decimal to be rounded.
If n is omitted then no decimal points.
Round(45.932) = 46
Round(45.932,1) = 45.9
Round(42.932,-1) = 40
Round(42.932,-2) = 42.93

Trunc(col/val,n)

N is the number of positions after decimal to be rounded.
If n is omitted then no decimal points.
trunc(45.932) = 45
trunc(45.932,1) = 45.90
trunc(42.932,-1) = 40
trunc(42.932,2) = 42.93

Ceil

Ceil(col/val)
Finds the smallest integer greater than or equal to the column/value
Ceil(45.980) = 46

Floor

floor(col/val)
Finds the largest integer less than or equal to the column/value
Floor(46.980) = 46

SQRT
Sign
Power(col/val,n)

Abs(col/val)
Finds the absolute value
3

Activity (6)

You've already reviewed this. Edit your review.
1 hundred reads
jayavardhankoti liked this
dayasc liked this
jaganj liked this
sonia liked this
sengaisaran liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->