Oracle consists of a comprehensive set of application building & end-user products, aimed at providing complete information technology solutions .Oracle applications are portable across wide range of plateforms & operating systems , from personal computer to large parellel processors. Oracle provides a flexible Database Management System (DBMS) - the Oracle Server - for storage & management of information used by applications . ORACLE SERVER The Oracle server is used to store & manage the information by applications. The latest oracle server is Oracle 9i manages a dbase with all the advantages of relational structure , plus ability to store & execute dbase objects such as procedures & triggers. It has following features:1.Storage of data in designated dbase areas. 2.Retrieval of data for applications , using appropriate optimization techniques. 3.Database security, & the tasks perfmitted for specific users. 4.Consistency & protection of data. 5.Communication & integration of data where dbases are disributed across a network.. Oracle applications may run on the same computer as the oracle server. Applications and tools supporting them may be run on another system.In the client -server computing environment , a wide range of computing resource may be used . Oracle server options :-

1.procedural option:- It provides a PL/SQL version 2 engine with in the Oracle server , which includes the ability to store dbase procedures , functions & triggers for use by application. 2.Distributed option :- It supports transactions which update data across more than one dbase in a distributed dbase network , employing two-phase commit . 3.parallel option :- It supports loosely-coupled systems. 4.Trusted Oracle :- Provides a set of additional high security features .


1Oracle text retrieval :- A technlogy that adds fully functional text retrieval capabilities to an oracle dbase . 2Pro * oracle :- A series of precompliers that allows oracle dbase access with in C , Cobol , PL/1 , Pascal , & Ada Programming Languages . 3Oracle Card :- An end-user interface for producing easy-to-use dbase applications incorporating graphics & multimedia features. 4Oracle Case :- A family of tools to aid the analysis , design & generation of oracle applications. 5SQL * Plus :- A tool that allows direct & interactive use of the SQL language to access the oracle server , using ad-hoc commands or by runnig command files.


A database management system requires a query language to enable users to access data . Structured Query Language(SQL)- pronounced ‘Sequel’ is the language was used by the most relational database systems. The SQL language was developed in a prototype relational database management system – system R-by IBM in the mid 1970 ‘ s . In 1979 , oracle Corp. introduced the first commercially available implementation of SQL . Features of SQL are described below :I.Sql is an english like language .It uses words such as select , update , insert , delete as part of its command set . II.Sql is the non-procedural language . In other words Sql does not requires to specify the method to the data . III.Sql process sets of records rather than a single record at a time . The most common form of records is table . IV.Sql can be used by a range of users including DBA ‘s , application – programmers , management personal . QUERYING DATABASE TABLES I.the most commonly uesd command ; it is used to retrieve the data from the database table. By using simple Select command : - This is Syntax :- select columnname from tablename ; For e . g :- select ename , empno , sal , hiredate from emp Where ename like ‘s%’; II.By using condtional retrieval :- The ‘ where ‘ clause is used for

g :– If we want to see those employee s whose salaries are ranging between 1000 & 2000 S :\> Select ename . deptno .The ‘where ’ clause must follow the from clause . 7566 . from emp Where mgr IN (7902 . To find out all employees who have one of three mgr numbers . • IN Clause :. It contains the condition that rows must meet in order to be displayed . low & high range . S:\> select em[pno . g :. from emp Where sal between 1000 and 2000 . • IS NULL operator :. If the characters & dates are used in the list they must be enclosed in a single quotations (‘ ‘) .It test values in a specified list .If we want to retrieve the information of those employees whose department name is ‘ Salesman ‘.The IS NULL operator specificallly tests for . 7788) . ename .It corresponds to the restriction operator of relational algebra. mgr . then :S :\> select ename . sal . hiredate From emp Where job = ‘SALESMAN ‘ . Syntax :.this purpose. OPERATORS IN ‘ WHERE ‘ CLAUSE • BETWEEN Clause :. sal . empno .select columns From table Where certain conditions are met . & inclusive of . deptno .This operator is used to tests value between . for e . For e . empno .

Null values taken up by one byte of internal storage.Like operator is used to select the rows that match a character pattern . If we want to list the names of those employees whose name starts from letter ‘S ’ S:\> select ename from emp Where ename like ‘S%’. III By using null values :. mgr From emp Where mgr is NULL .values that are NULL . it is necessary to convert The null values to a number . We uese the ‘ NVL ‘ function to Convert the null value to a non – value.g : – .The character pattern matching operation may be referred to us a ‘ wild – card ‘ search . Two symbols can be used to construct the search string . any single character. Unassigned . Symbol % Represents any sequence of zero or more characters . In order to Achieve a result for all employees . For e. For negating we use :• • • • NOT BETWEEN IN NOT IN . then . LIKE :.A null value is not the same as zero. S:\> select ename . Null values are handelled correctly by SQL . unknown or inapplicable. Zero is a number .A null value is a value which is either unavailable . So to find out all employees who have no managers .

For e .0) Annual _sal from emp .g :.Normally . To reverse this order . the command word DESC is specified after the column name in the ‘ ORDER BY ‘ clause . Group functions can be used to return . Multiple columns may be specified after The ‘ DISTINCT ’ clause & the DISTINCT affects all selected columns . V By using ORDER BY clause : . VI By using GROUP BY Clause : . hiredate From emp ORDER BY hiredate desc . • Date values earliest first . g – S:\> select ename .To display the distinct values of deptno & job enter : S:\> select DISTINCT deptno . ORDER BY must always be the last clause in The select statement . • Character values alphabatically .S:\> select ename . job from emp . IV By using DISTINCT Clause : .The GROUP BY clause of the select statement is Used to divides rows into smaller groups . The default sort order is in ascending order : • Numeric values lowest first . job . sal*12 +NVL(comm . For e . the order of rows returns in a query . This display a list of all the different combinations Of jobs & department numbers . May be used to sort the rows .The ‘ Distinct ‘ Clause is used to eliniminate the The duplicate values in the result .

along the list of columns Specified in the GROUP BY clause .sum (sal) From employees Where dept_id<60 Group by ROLL UP(dept_id .Roll up grouping produces a result set containing the The regular grouped rows & the subtotal values . avg (sal) .Information for each group . For e . avg (sal) From emp Group by job . Syntax :Select [column . job_id) .before dividing them into group . The roll up operator Can be used by the report writers to extract statistics & summary Information from results sets. max (sal) . VIII By using Roll up operation : . Rows may be pre – excluded with a ‘ WHERE ’ Clause .] group_function (column) from table [where condition] group by [ROLL UP] [group_expression] For e .g :S:\> select dept_id . sum(sal) . The Roll up operator delivers aggregate & subaggregates for Expressions within the group by statements . .g – S:\> select job . g : – S:\> select job .…. The Roll Up operator creates Groupings moved from right to left . VII Having Clause :.The ‘ Having ‘ clause is used only with the expressions and / or Columns that are specified with the ‘ GROUP BY ’ clause . min (sal) from emp Where deptno =20 Group by job Having avg (sal)>1000 . For e .job_id.

Similar to char but can store variable number of characters .The cube operator is an additional switch in group by in select statement.…] group_function (column) From table [where condition] group by [CUBE] group_by_expression .The cube operator is used with an aggregate function to generate additional rows in a result set .VARCHAR2 :.To store character type data. . 3. min . sum . which is of a particular type . sum (sal) From emp Where dept_id < 60 Group by CUBE (dept_id . The different data types available are [column.NUMBER :. max . Syntax :. job_id .Count .The Cube operator can be applied to all aggregate functions including Avg .IX Cube operation : . It is used to produce results set that are typically used for across – tabular reports . A particular column in a table must contain similar data . ORACLE DATATYPES The information in a data base is maintained in the form of tables .Stores fixed & floating point numbers . job_id) .g : S:\> select dept_id . for e .CHAR :. Each table consists of rows & columns to store data . 2.

data of size 255 bytes length (n). 5.This type of data is used to store upto 2GB of characters . 7. Max. VARCHAR2 (n) 3. sound . NUMBER ( P . upto 2000 bytes per column / row .stores point. given 1. Variable Variable length for each numeric row . data .LONGRAW :.LONG :.Used to store binary data such as graphics . The Max Maximum . space pre required -sicion for a ( P) is 38 . per column / row . etc .in – time values in a table . Varirable Variable length for each character row . data .Contains raw binary data otherwise the same as a long column.RAW :. S) . 6.DATE :. CHAR (n) 2. Data type Descripti on Column Length (in bytes ) Fixed Fixed For length every row in character the table .4.

4712 A. Its range is upto 2GB . DATE 5. column is 21 bytes .D . AGGREGATE FUNCTIONS IN ORACLE 1COUNT () :.g :S:\> Select count (*) from emp . Fixed at 7 bytes for each row in a table . For e.The COUNT() function is used to determine the number of rows or non NULL column values . Variable legth character data .4.C ) to (Jan 1. 4712 B. Default format ( DD: MM : yy) . LONG Fixed length date & time data ranging from (Jan 1 . .

g :S:\> select max ( sal ) from emp . 5AVG () :. dname .2SUM () :.This function is used to calculate largest value of all selected values of a column . g :S:\> Select sum ( sal ) from emp . g :S:\> select empno . deptno . There types of joins : 1. they make an equi join . Table prefixes are utilized to prevent ambiguity & the clause specifies the columns being joined . For e . QUERYING MULTIPLE TABLES A join is used to when a Sql query requires data from more than one table on data base . 3MAX () :. Rows in one table may be joined to rows of another table according to rows common values existing in corressponding columns . Equi join :.This function is used to calculate the smallest value of all selected values of a column . For e . 4MIN () :. For e .This function is use to determine the sum of all selected columns .This function is use to calculate the average of all selected values of a column . For e .g :S:\> select min (comm ) from emp . For e . emp . ename .When two tables are joined together using quality of values in one or more than one columns . g :S:\> select avg (sal ) from emp .

deptno . loc . dept .If there are values in one table that do not have corressponding values in other . to distinguish the column name from one another . dept . Outer join :. dept where emp . each row of one table matches every row of other table . The syntax of the command for joining the table to itself is almost same as that for joining two different tables . For e .dept no (+) = dept . The self join can be viewed as join of two copies of the same table . aliases for the actual table names are used . 2. 4. ename . Here deptno columns exists in column name should be qualified with the table name. in an equi join that row will not be selected by using the the outer join symbol ( + ) . dname . from emp . ename . but SQL performs the command . Cartesian join :. Self – join :. emp.deptno . loc .from emp . The symbol ( + ) cannot be on the both sides. The corressponding columns for that row will have NULLs. dept where emp . from emp . g :S:\> select empno . The table is not actually copied . For e.To join the table to itself it means that each row of the table is combined with itself & with every other row of the table .g :- .deptno . deptno = dept . Table name aliases are defined in the ‘From ‘ clause of the query .When no ‘ where ‘ clause is specified . This results in a cartesian product . deptno . For e . 3. If the symbol (+ ) is placed on the other side of the Equation then all the employees details with no corressponding Department name & location will be displayed with NULL values in DNAME & LOC column .g :S:\> select empno . dname .

SET OPERATORS Set operators are used to combine two or more queries into one result . ) . 12INTERSECT :.The relation ship between EMP & SALGRADE table is a non-equi join . For e . salgrade S Where E .hisal .g :S:\> select job from emp Where dept no= 20 UNION S:\> select job from emp Where dept no = 30 . from emp E . Only a final query is ends with a semicolon ( . e . The number of columns in the queries must be the same & of the same data type . using the ‘ UNION ‘ clause .ename from emp WORKER . Data type of corressponding columns are same .The ‘ INTERSECT ‘ operator displays the jobs . for e . sal . but their output is merged . mgr = MANAGER . The ‘ UNION ‘ clause marges the outputs of two or more queries into a single set of rows & columns . s . sal between s. The queries are all executed independently .grade . Emp MANAGER where WORKER . To evaluate employee’s grade .losal and s.Multiple queries can be merged together & their results are combined . mgr . their salary must be ‘ BETWEEN ‘ any pair of the low & Hisal ranges .g :S:\> select ename . name . Non – equi join :. manager .S:\> select worker . 5. in that no column in EMP corressponds directly to a column in SALGRADE . The relationship is obtained using an operator other than the equal ( = ) . There are three types of set operators given below :11UNION :.

It has following features which are given below :1The result of one query is dynamically substituted in the condition of another . NESTED QUERIES When one query is defined in another query is called nesting queries .The ‘MINUS’ operator display the list of those jobs which are unique to department 20 . 4There is no limitation to the level of nesting of queries in ORACLE 8 . g :S:\> select job from emp where deptno = 10 MINUS S:\> select job from emp where deptno = 10 MINUS S:\> select job from emp where deptno = 30 . 13MINUS :. 5When using relational operators .which are common to department 10 & 20 . ensure that the sub – query return a single row output 6In some cases . 3The return value of inner query is then substituted in the condition of the outer query . g :S:\> select job from emp where deptno = 10 INTERSECT S:\> select job from emp where deptno= 20 . For e . 2Sql first evaluates the inner query / or sub query with in the ‘ where ‘ clause . the ‘ DISTINCT ‘ clause can be used to ensure . For e .

Functions are of different types :1)Character Functions :. They accept one or more than one arguments & return one value . 3 Select ename from emp where empno IN ( select empno from incr ) . 5Alter date formats for display . For e . 6Convert column data types . Functions are used to manipulate data items . FUNCTIONS Functions make the basic query block more powerful . g :1Select ename from emp where dept no = (select deptno from emp where ename = ‘ MILLER ‘) . 2Select ename from emp Where sal = (select max ( sal) from emp ) . 4Manipulate output for group of rows . Performs calculations on data .Single row character function accept character data as input & can return both characters & number . Functions can be used to :1.single valued output . 3Modify indidvidual data items . & are used to manipulate data values .

3 . starting at the position number pos . 4 ) .This function is used to concatenate the two words . For e . 5 ) From dept . For e . g :. g:.This function is used to captilized the first letter of each Word of the string .This function is used to force the user input to capitals For e . f) LTRIM :. If char is not specified will trim any blanks from the Left where ‘ CHAR / s ‘ is treated as a set not as a . INITCAP (Loc) From dept . d) CONCAT :.S:\> select substr ( ‘ ORACLE ‘. The following character functions are :a) LOWER ( col | value ):. g :S:\> select INITCAP ( Dname ) . b) UPPER :. g :. e) SUBSTR :.This function removes from left leading occurences of Char specified . For e . c) INITCAP :. For e .This function forces alpha charcter values which are in uppercase or mixed case into lower case . LOWER( ‘ Sql Course ‘) from dept . job ) “ JOB “ From emp where empno = 7900 .S:\> select ename From emp where ename = UPPER (& Ename ) .This function returns the string of n characters form the Column & literal value . 2 .S:\> Select CONCAT (ename . substr ( ‘ Dname ‘ . g :S:\> select LOWER ( Dname ) .values .

‘ A ‘ ) . from dept .g :S:\> select dname .g :S:\> select CEIL( sal ) . 2) NUMBER FUNCTIONS :. g :S:\> select sal .This function removes from the right trailing occurrences of Character specified . LTRIM ( dname . g :S:\> select TRUNC(2. ‘ AS’) . CEIL (99.678 . ‘ GHS’ ) . LTRIM (dname . 2TRUNC () :. The number of numeric functions are :1ROUND () :. +2 ) from dual . For e . ‘ASOP ‘) from dept .Round function is used to round the column expression or value to n decimal places .The ‘CEIL ‘ function is used to find smallest integer greater than or equal to the column .Raises the column / expression to the nth power . Can also be negative .g :S:\> select dname . 3CEIL ():.For e . +1) from dual . 4POWER () :. RTRIM ( dname . g :S:\> select ROUND(2. For e . ‘A’) . RTRIM (dname .The ‘ TRUNC ‘ function is used to truncate the column or values to n decimal places . For e .string . .Number function accept numeric accept numeric input & return the no of numric values . For e . expression or value . g) RTRIM :.9 ) . CEIL ( 101. 4) from dual . LTRIM (dname .6 ) from emp . RTRIM (dname . power ( sal .456 . ‘ N ’) . For e .

Sysdate is a pseudo column that returns the current date & time . For e . ADD_MONTH :.The ‘ MOD ‘ function is used to find out the remainder of value 1 divide by value 2 . ‘ 05 – NOV – 88 ‘) from emp Where months_between (sysdate .g :S:\> select mod ( 12 . e = 2. .Add n number of calender months to date .g :S:\> select sysdate from sys.3 ) from dual . It selects sysdate from a table called dual table .It finds the square root of the any value specified in brackets . add_months ( hiredate . hiredate ) > 59 .Date functions are operate on oracle dbases . SQRT ():. months_between ( ‘ 01-JAN – 84 ‘. 3. If date 1 is later than date 2 . hiredate) . 7.g :S:\> select EXP (4) from dual . 3) . for e. MOD () :. SYSDATE :. MONTHS_BETWEEN :. All date function returns the value of DATE datatype except month_between which returns a numeric value .g :S:\> select SQRT(144 ) from dual . g :S:\> select months_between ( sysdate .Finds the number of months between date 1 & date 2 .Types of date functions are :1.g :S:\> select hiredate .n must be an integer & can be negative . The rows can be +ve & -ve . 3.71828183 for e. 3) DATE FUNCTION :. For e.dual .Returns the e raised to the nth power . 2.5EXP ():. For e . For e .

TO_NUMBER :.dual . sal From emp Where sal >= To_number ( ‘ 1500 ‘) . DDTH . Next_day (hiredate . g :S:\> select hiredate . ‘ Friday ‘ ) . 4. trunc ( sysdate . 7. TO_CHAR :.This function is frequently used to change date format from the default to an alternative display format . otherwise returns the first of the following month . g :S:\> select sysdate . 8. g :S:\> select to_char (sysdate . 6 ) from emp . ename . trunc (sysdate . For e . ‘ year ‘) from sys.The to_number function is used to transform a number store as a character to number datatypen . TRUNC :. . -3 ) from emp .It displays date of the next specified day of the week following date1. job . round (sysdate . ROUND (Date1 . ‘month ‘) .This function returns the first of the month date 1 if date1 is in the first half of the month . For e . g :S:\> select sysdate .MONTH YYYY ‘ ) from sys .For e . 5. For e . next_day (hiredate . ‘ DAY .dual . ‘ Month ‘ ) :. 6.This function finds the date of the first day of the month containing in date1 when char = ‘ month ‘.Add_months (hiredate .dual . g :S:\> select empno . ‘ month ‘) from sys. NEXT_DAY :. For e .

varchar2 ( 20 )) . 2) ) . item_name varchar2 (20 ) . . 1ALTER TABLE COMMAND :.The create table command is used to create the table .Alter table command is used to add a column in a database table Syntax :Alter table table name add ( column_name For e . It include the following set of commands : CREATE TABLE COMMAND :. ). g :S:\>Alter table emp add ( spouses_name type (size ) ) . modify .DATA MANIPULATION & CONTROL -_I 1) DDL COMMANDS :. These commands have an immediate effect on the database . column_name type (size ) . or remove dbase structure . including tables . For e . item_code varchar2 (4 ) . Syntax :Create table table name ( column_ name type (size) . & also record in the data dictionary . DDL is the subset of sql commands use to create . It is the one of the simplest forms of this command is where the basic information for each column defined together with their data types & sizes .DDL stands for ‘ Data Definition Language ‘. item_price number (5 . g :Create table item ( item_no number ( 5 ) .

ename . value 3 . NULL . It includes following DML commands :3INSERT COMMAND :. … ) . Column name 2 . 20 ) .We can insert values into the dbase table via ‘INSERT ‘ command . Syntax :. g :. S:\> drop emp empno .2DROP TABLE / COLUMN COMMAND :.S:\> insert into emp Values ( 7311 . The SQL DML includes a query language base on both the relational algebra & the tuple of the relational calculus . g :. For e . sal ) Values ( 7902 . 3000 . 7001 . We can delete column by using the drop table command . When values are provided to the insert into command it is Called a single row insert . Column name 3 . It is possible to a new row with values in an each column .S:\.We can delete entire datatbase table using drop table command . g :S:\> drop table emp . 15DML COMMANDS :.DML stands for ‘ Data Manipulation Language ‘ commands . in which case the column list is not require . …) Values (value 1. ‘ 18 – Apr – 95 ‘. ‘ TOM ‘ . For e .S:\> insert into emp ( empno . ‘ pankaj singh ‘ . 7000 ) .> insert into table name (column name 1 . 4UPDATE Command :. ‘ CLERK ‘ .Columns in a table are updated using the update command .value 2 . For e. Updation can be . Values of a single column or group of columns can be updated .

carried out for all the rows in a table or selected rows . The advantages of the view are :- .Expressions can also be with update . g :S:\> delete from emp Where ename = ‘ SCOTT ‘ . A set of rows can be deleted from the table . VIEWS A view is a virtual table & is like a window to a table .Rows can be deleted from the table using the delete command . Syntax :Update table (alias ) Set column = expression Where condition For e . The entire row is deleted from the table . g :S:\> update emp Set job = ‘SALESMAN ‘ hiredate = sysdate where ename = ‘ SCOTT ‘ . but derives from the table it is associated with . Syntax :DELETE from table [ Where condition ] For e . It doesnot have any data type of its own . 5DELETE COMMAND :.

2While manipulating tables . update . 9Complicated queries are simplified using views Views can be created using ‘ CREATE VIEW ‘ command . 8Critical data in the database table is safeguarded as access to such data can be controlled by using views . 7As a view does not store any data . For e. column 2 .g :S:\> create view D10 emp As select empno . Syntax :Create view [or replace ] [force ] view View name [column 1 . the redundancy problem does not arise . sal From emp Where deptno = 10 . & delete commands can also be used with views .6Any updation of rows in the table will automatically reflect in the view . MANIPULATING BASETABLES THROUGH VIEWS We can manipulate the basetable through views from the following ways :1By using insert . certain rules are applicable . ename . …] . .

Droping a view We can drop an existing view using drop view command . For e . g :S:\> drop view dept30 . e) The view must not use subqueries . This command removes the view definition from the database . Syntax :Drop view viewname .3The crieteria that determines whether the operations are througha view are :a) The view must be based on the single table . f) The views must not be read only view . Rows & columns are not affected since they are stored on the tables from which view was derived . d) The view must not use group by or having in its definition . c) The view must not specify ‘ Distinct ‘ in its Definition . . b) The view must not have columns that are aggregate function .

APPLICATIONS PRIVILEGES MANAGEMENT The management of the application privileges are done by the following :1By roles that collects the privileges . views . 0 provides three standard roles : connect . 4Resource role allows to create oracle objects such as tables . views & other objects That he creates . & password & own tables . . & system administration .II DATA BASE SECURITY & PRIVILEGES Oraclae provides extensive security Features in order to safeguard the user ‘s information from both unauthorized accesss & internal damage . 5DBA role has the system privileges such as creating users .DATA MANIPULATION & CONTROL . resource . DBA . Database object privileges give the user the ability to perform the certain operation on certain specified classes of objects . which determine the type of access that each user needs . An oracle role is set of privileges . Specific privilegs can be grant to roles & roles are assigned to appropriate users . Database system privileges let the user execute a specific set of commands . This security is provided by granting or revoking privileges on a user – by – user & privilege – by – privilege basis . 2Oracle 8 . depending upon his / her status & responsibilities . creating databases . Every oracle user has a username . etc . 3Connect role only allows to use oracle .

This simplifies the administrative tasks involved in the management of pivileges . c ) Oracle analyzes each query to find out the fastest paths to the data . in all the SQL statements . d ) Indexes are used to reference records . f ) Indexes do not have to be activated or deactivated . When granted to the users . Roles are can be thought of as a set of privileges . the privileges can be granted to the role & the role is granted to the each user . GRANT < priv_list > TO < role_name > A role is then granted to user . e ) Indexes are store seperately from the actual data .6Role can be created by Create role <role – name > [Identified by <password> ] . . Instead of granting individual privileges to the each user . Once the role has been created . the privileges can be granted . ENHANCING PERFORMANCE We can enhance the system performance by following ways :1Indexing & clustering are two common way of enhancing system performance in retrieving information from the table . 2SQL syntax does not change with these methods . as these database objects are transparent to the user . b ) Index can also be used to ensure that no duplicate values are entered into a column . 3INDEXES a ) Indexes provies a fast access path to columns that are indexed .

It also increments the value .A Sequence is a database object used to generate unique integers for use as a primary keys . etc are the examples of a database objects . by 1 MAINTAINING DATABASE OBJECTS Data base objects are created & stored in a dbase .< seq_name > NEXT_VAL returns the next value of the sequnce . Tables . ‘ HANS ‘ . For e . ‘START WITH ‘ is the number with which the sequence will begin . sal ) Values ( empno . g :S:\> Create sequence empno INCREMENT start with 8890 Insert into em ( empno . clusters . 6000 ) . < seq_name > URRVAL returns the current value of sequnce . . Syntax : Create sequence seq_name [ Increment by < n > ] [ start with < m >] .g ) With every data manipulation the appropriate index is automatically updated . ename . nextval . views indexes . A sequence is created through the ‘ CREATE SEQUENCE ‘ command . The default increment value is 1 . SEQUENCES:.

Maintainence of database objects involves creating . A user can grant access to hi database object to other user . database_ priv ] To < user_name > Indentified by < password > For e . g :S:\> GRANT CONNECT . It requires DBA privilege . Syntax :GRANT < database _ priv [ . Modifications are done using ‘ Alter Table ‘ command . Syntax :ALTER TABLE < table _ name > { ADD ( < col – element > | < constraints > …… [ MODIFY < col _ elements > ] } ALTER cluster < cluster_name > GRANT :. except that user can change his / her passsword . S:\> GRANT ALL On emp To public . altering & deleting them from the dbase .The ‘ GRANT’ command is used to craete user & grant access to the database . . Deleting is done by using ‘ Delete Table ‘ command . RESOURCE To thomas Identified by enquist .

‘ PURCHASE ‘ . FROM S :\> Revoke update on emp from public .The ‘ REVOKE ‘ command is used to revoke the database privileges from the user by DBA . When this command is executed . S:\> REVOKE CONNECT . ‘ DELHI ‘ ) . COMMIT :. g :S:\> insert into dept values ( GO .The ‘ COMMIT ‘ command is used to make the changes permanent . ROLLBACK :. g :S:\> insert into dept values ( 50 . For e . For e.The ‘ ROLLBACK ’ command is used to undo the changes performed through insert . For e . ‘ CORRICULUM ‘ . The user can be revoke the grants to other on his objects . ‘ DELHI ‘ ) . The ‘ ROLL BACK ‘ is not use after the commit command . Save point identifies a point in a transcation to which one can later rollback via ‘ROLLBACK ‘ command . S:\> commit .REVOKE :. S:\> select * from dept . S:\> savepoint s1 . RESOURCE . user] > . S :\> Update emp set deptno = 60 Where ename = ‘ SMITH ‘ .g :thomas . . S :\> ROLLBACK to savepoint s1 . Syntax :REVOKE < dbase priv > FROM < user [ . ROLLBACK ‘ command is used to discard path or all the work the user has done in transaction .

3PORTABILITY :. & branches may be employed to control the procedural flow of the program . programs may be transported across any host environment in which ORACLE & PL / SQL are supported .END PL / SQL ( PROCEDURAL LANGUAGE SQL ) PL / SQL (PROCEDURAL LANGUAGE / SQL is an extension to SQL .Since PL / SQL is native to oracle . meaninig that programs can be divided into logical blocks . incorporating many of the design features of the programminng languages . 4INTEGRATION :.Conditional statements . loops . Variables are declared locally to the block in which they will be used . making PL/ SQL Powerful transcation query language . This can avoid the need to place commands into separate trigger – steps . The advantages of the PL / SQL are as following :1BLOCK STRUCTURE :.PL / SQL is playing an . each block containing the the language resources that are logically required in that unit .PL / SQL is a block structured language . It allows the data manipulation & query statements of SQL to be included with in the the block structure & procedural units of code . 2FLOW OF CONTROL :.

The use of PL / SQL can help to improve the perfromance of an application . The variables & dataypes of PL / SQL are compatible with those of SQL . The PL / SQL block structure is given below : DECLARE < declaration > BEGIN < Executable Statements > EXCEPTION <Exception – handlers > END . PL / SQL BLOCK STRUCTURE As we know that the PL / SQL is a block . The DECLARE section is optional & used to declare PL / SQL objects such as variables that are to be referenced in the block .increasingly central role in both the RDBMS & in ORACLE tools . Finally . the EXECPTION section is used to trap the predefined error condtions . which in turn may be just a part of the whole unit of code . Every unit of PL / SQL compromises one or more blocks . The BEGIN & END statements are mandatory . or nested one within another . & enclosed the body of the of actions to be performed . or a nested block with in it . 5PERFORMANCE :. the gap between convenient access to dbase technology .structured language . Therefore . These blocks may be entirely separate . One block may represent just a small part of another . PL / SQL bridges . DECLARING PL / SQL VARIABLES & CONSTANTS .

including variables . and are allowed to change their further assignments . Variables are declared in the DECLARE section of the PL / SQL block . user – defined exceptions & contants . Dept no number ( 4 ) = 30 . g :Temp_name emp.ename %TYPE . Advantage of this method of defining a variable that . Age number ( 3 ) . All statements must end with a semicolon ( . Constants are declared by specifying the keyword CONSTANT before the data type . g :DECLARE X number . . g :Mname char (20 ) . cursors . These rules are apply to all declared objects . whenever the type & size of a column in the table is changed . For e . For e . Declaration must involved name of the variables followed by its datatype .PL / SQL supports a variety of data types which may optionally be assigned a value when declare . including any sub blocks nested within it . SCOPE & VISIBILTY OF A VARIABLE The ‘ scope ‘ of an object is the region of the program over which that object may potentially be used . Constants are identifiers which had a fixed value that must be assigned when a constant is declared . it is automatically reflected in the variable declaration . The general syntax :Var_name type [ : = < value > ] . the attributes % TYPE is used . To avoid the type & size conflict between a variable & the column of the table . The scope of an object is the complete block in which it is declared . Objects declared in subblock are only available until that subblock has ended . For e . ) .

ASSIGNMENTS & EXPRESSIONS The PL / SQL assignment statements allows a value to be assigned or reassigned to a variable after the declare section of the block . The expression may be literal . most of the expressions available in select clause of an SQL query are available here . the variable ‘ x ‘ from the main block still it exists . For e . BEGIN .. END . .BEGIN . g :V_count : = v_count + 1 . The functions supported in PL / SQL expression are discuss later in this unit . Syntax :Identifier := expression . or any complexity of the expression necessary to determine the value to be assigned . During the subblock . to receive the value of ‘ expression ’. Where ‘ identifier ‘ is the name of the target variable .. DECLARE Y number . variable ‘ X ‘ of the subblock disable the use of variable ‘ x ‘ from the main block until the subblock’s variable from the main block until the subblock’s variable reaches the end of its scope . the name of another existing variable . END . but has no visibilty ... In the example above . Generally . The variable to receive the new value must be explicitly named on the left of the assignment operator . or field .

Male : = upper ( title ) . Female : = not male .Ann_sal : = month sal*12 + NVL ( COMM . The assignments to boolean variables may be ‘ TRUE ‘ or ‘ FAlSE ‘ . Lev : = 6 . 0 ) . or the result of a boolean expression . ORACLE PRACTICAL FILE CREATED BY . Overpaid : = ann_sal > 35000 . Switch 1 : = TRUE . Salary_ok : = not over paid . V_name : = ‘ KING ‘ .

C. Using: ROLLBACK A rollback does exactly the opposite of commit . All transactional locks acquired on tables are released .Varun bhardwaj SUBMITTED BY :NAME :. CLASS :.All transactional locks acquired on tables are released . it ends the transaction but undoes any changes made during the transaction .KAMALJIT SINGH.A – II Rollno= 10739 1 2 Using commit: A commit ends the current transaction and makes permanent any changes made during the transaction . Syntax: COMMIT. syntax : ROLLBACK[work][to[savepoint]savepoint] Where: .B.

explicit cursors. Example: Select empno. WHAT IS A CURSOR ? The oracle engine uses awork area for its internal processing in order to execute an sql statement.ename . explicit cursor is declared within the declare section to specify the query to be executed for the cursor . 1. 2. When a save point is used with a rollback statement parts of a transaction can be undone . Types of cursors: Cursors are classified in two ways .salary from employee where deptno=20. SYNTAX : Savepoint savepointname.Implicit cursors. When the sql statement is not associated with an explicitly declared curscr then oracle implicitly opens a cursor to process sql statements .an active save point is one that is specified since the last commit or rollback . Savepoint: is optional and is used to rollback a partial transaction as far as the specified save point : Creating save point : Save point marks and saves the current point int the processing of a transaction.job .then the open statement executes the query associated with the curs or to form the active set. This work area is private to sql’s operations and is called a cursor .Work:is optional and is provided for ansi compatibility. 2 . .

Sign up to vote on this title
UsefulNot useful