Database:It’s a collection of organized data where the data will be stored in the form of rows and columns

. Where each row is a called a record and each column is a field. In the database the data is stored in the objects, which are called the database objects. So first the objects should be created and in order to create an object the data is to be defined and that data should be defined in the form of columns and those are called fields. After defining the fields the rows or records can be inserted dynamically. Oracle:Oracle is a package, which is developed by Sir E F Codd in 1969 and implemented by Oracle Corporation in 1971. But this has got the recognition of ANSI and ISO in 1979 and used as the most popular database application by the programmers. This is a ORDBMS (Object Relational DataBase Management System) where DBMS is a software by using which the data can be 1.Defined 2.Inserted 3.Stored 4.Accesed 5.Deleted etc. Oracle provides two additional features, which are 1.Relational:-This feature allows the user to establish a relationship between more than one database objects .The relation can be any of the following types. 1.One to One. 2.One to Many. 3.Many to One. 2.Object:- By using the objects a set of related data can be bundled and their features can be available to any database objects later on. This object concept supports three main features. Those are:1.Inheritance (Attaining property of one object to another) 2.Encapsulation:-(Wrapping up of different types of data into a single bundle.) 3.Polymorphisim (Using a data for more than one purpose) Normalization:In an application development cycle arrangement of data takes an important role. This arrangement should be done by keeping all the data and their activities in mind. This process is called normalization. This normalization can be done by using the constraints which are used to restrict the data to a particular extent and also by establishing the relationship between two different data. There are two types of constraints: 1.Integrity constraints (To establish the data integrity in an object) 2.Referencial constraint (To establish relationship between the data of more than one objects).

Maintenance of data in oracle database:Data can be maintained in the database by using some objects, which are called database objects. There are 6 different objects in the database: 1.Table 2.View 3.Sequence 4.Index 5.Cluster 6.Synonym But among all these the table is the main object and the rest of all need the help of the table to function themselves. Oracle is a software based on client-server technology where database the server and though it can accessed by any number of users each called the clients. So in order to login oracle we must have to be connected with the database through any of the users. There are 6 users, which will be created by default while installing oracle. Those are 1.scott , 2.system, 3.Demo ,4.sys ,5.po8 6.dbsnmp To store the data in the database first we have to create any of the database objects. There are 4 major components in oracle application which are 1.Sql 2.Pl/SQL 3.SQL*PLUS 4.Dev-2000 1.SQL: This is a non-procedural structure oriented language because it follows some particular syntax. This is developed by E F Codd and earlier known as SEQUEL.There 3 types of languages in SQL,which are 1.Data definition lang:-Used to define the and remove the definition of data.There are 4 commands in this language having different purposes. 1.create 2.drop 3.Alter 4.Truncate 2.Data manipulation lang:-Used to make any manipulation or changes over the existing data having 3 commands in it 1.insert 2.update 3.Delete 3.Data/Transaction control language:-The commands in this language can further devided into two more parts. 1.Non data base comands:-Not related to the database directly and those are 2.commit 3.Rollback 4.savepoint 2.Database commands:-Related directly to the database and those are

1.grant 2.revoke In addition to all these one more SQL command is there which does not undergo any of the commands.That is “rename”. While creating a table at first we have to define the fields each according to their datatypes.There are different types of data we use in our day to day life and oracle also provide some datatypes to deal with those data. A.Character data:1.char(w):-This is a fixed length character data type where any character data upto 255 characters can be stored. The default width for a character data is 1. 2.varchar2(w) :-This is a variable length character data type which can accept maximum 2000 characters into it. Ch varchar2 3.long:-This is also variable length character data type which can accept maximum 2gb data into it. This is generally used for storing large data like resumes, receipts etc. But only one long field is allowed per a table. B.Numeric data:1.number(w):-This data type accept any numeric data upto 39 digits.If any decimal data is to be stored in a field of number data type that can be stored in the form of number(n,m). Where n is the total width for the field ,m for the decimal number and n-m for the whole part. 2.smallint:-To store only whole numbers. 3.float:-To store the floating point i.e. very large or very small values. C.Date to store any data data between 1st jan 4712 bc to 31st dec 4712 ad in the format ‘dd-mon-yy’ . D.Pictures and graphical data:1.Raw:-Used to store the pricture data upto 256 character length. 2.Long raw:-Used to store picture and graphical data of large size and stores upto 2gb .Only one long raw is allowed per a table. E. Large objects:1.BLOB:-Binary large object 2.CLOB:-Character large object 3.NCLOB:-National character large object Creating a table:A table can be created by using “create table” command as the following syntax:syntax:create table <<tablename>>(field1 datatype(w),field2 datatype(w),...............,fieldn datatype(w) ); Ex:-

A. create table your_table(name varchar2(15),last_name varchar2(12), do_birth date,age number(3),address1 varchar2(20),address2 varchar2(20)); 2. create table stud_01(rollno number(3),name varchar2(10), doj date,marks1 number(3),marks2 number(3),marks4 number(3)); Whenever oracle is installed it creates 4 tables by default. Those are 1.emp 2.dept 3.salgrade 4.bonus Note:1.A table name can be any name without a space and it should be unique the current user. It does not allow any special symbols in it except the underscore ( _ ). 2.Every SQL commands should end with a semicolon. B.Alter:-Used to change the structure of a table created. It can be done in three ways. 1.Adding new fields:syntax:-alter table <<tab name>> add (f1 dtype(w),f2 dtype(w),.......); ex:-alter table stud add (tot number(3),avr number(5,2)); 2.Changing the width of existing fields:-Width of an existing field can be increased and also can be decreased if the table is empty. syntax:-alter table <<tab name>> modify (f1 dtype(new width),f2 dtype(new width)); ex:-alter table stud modify(tot number(4),avr number(6,2)); 3.To drop a column:syntax:-alter table <<tab name>> drop(col name); C.Drop:-Used to remove the existence of a table in the database. syntax:-drop table <<tab name>>; ex:-drop table stud; D.Truncate:-Used to delete all the records from a table permanently. syntax:-Truncate table <<tab name>>; ex:-truncate table stud; B.Data manipulation commands:1.Insert:-Used to insert the records to an existing database table. This can be done in 4 different ways:1.To insert all the values and for a single record:syntax:-insert into <<tab name>> values(f1val,f2val,....,fn val); ex:-insert into stud values(101,’aaa’,45,66,78); 2.To insert for a few columns but for one record:syntax:-insert into <<tab name>> (f1,f2,f3,...) values(f1 val,f2 val,f3 val,...); ex:-

a. insert into stud(rno,name,sub1,sub2,sub3) Values(102,’aaa’,56,78,98); b. insert into stud(name,sub1,sub2,sub3,rno)values(‘cccc’,89,55,65,103); 3.For all the fields and more than one recs:syntax:-insert into <<tab name>> values(&f1,&f2,&f3,....); ex:-insert into stud1 values(&rno,’&name’,&sub1,&sub2,&sub3); 4.For few fields and more than one recs:syntax:-insert into <<tab name>> (f1,f2,f3,...) values(&f1,&f2,&f3,...); ex:-insert into stud (rno,name) values(&rno,’&name’); • To insert data from another table:Data to a table can be inserted from another existing table if the structure of both are same. syntax:-insert into <<tab name>> select */field names from <<existing tab name>>; ex:a.insert into stud(rno,name,sub1,sub2,sub3) select * from stud1; b.insert into stud(rno,name) select rno,name from stud1;

2.Update:Used to update a field or column with any value or based on the data of another field from the same or different table. syntax:update <<table name>> set <<field name>> = <<value/expr >>,<<field2>>= <<value/expr,..........., where condition; The where condition sholud be given while updating a particular row otherwise that is not necessary. Ex:-update student set sname=’eeee’ where rollno=105 2. update student set tot=sub1+sub2+sub3,avr=sub1+sub2+sub3/3; By using logical operators:The logical operators ‘and’ and ‘or’ can be used with the condition to combine more than one conditions. ex:3.Delete:-Used to delete a record or more than one records temporarily from the table. syntax:-delete from <<table name>> where <<condition>>; ex:1.delete from student where rollno=104; 2. delete from student; Data control language :used for retriving the datas from a database object e.g. tables. * from <<table name>>;

tot.sname.commit:used to save the changes permanently to an object. 2. Logical operators:While giving the conditions by using where clause if more than one condition are required for a query then logical operators can be used.. ----selects the datas from a table only with the mentioned fields.. It acts just like * from field1.field2. Those are 1. syntax:-savepoint <<savepoint name>> ex:-savepoint rno. B.. ex:1.. from <tablename>>.savepoint:allows to create a private area by the user which is saved temporarily by means of which the user can rollback the changes up to that particular point.or Truth table:and:cond1 cond2 res T T T T F F F T F F F F OR:T T F F T F T F T T T F FOR RES AND DIV:- . C. while rolback:rolback to <<savepoint name>> ex:-rollback to s1.and 2.rollback:used to get the changes cancel out since the last commit . syntax:commit. 2. syntax:-rollback. D.----selects all the datas from a table..avr from stud.

TA. * :-stands for all. Q.DA OF 28%.PF. ex:1. RES=’PASS’ WHERE SUB1>=35 AND SUB2>=35 RES=’FAIL’ WHERE SUB1<35 OR SUB2<35 OR DIV=’FIRST’ WHERE RES=’PASS’ AND AVR>=60.’MANAGER’). symbols and operators:symbols:1.-(sub).g.SELECT * FROM EMP WHERE JOB IN ‘MANAGER’.SELECT * FROM EMP WHERE DEPTNO IN (20. Unary:+. e. HRA.ENAME. 3.+(add). UPDATE STUD SET AND AVR<50. NOT IN:-retrieves the row for which the condition does not match.UPDATE STUD SET AND SUB3>=35.IN:-Retrieves the data where the condition matches./(div) 3. UPDATE STUD SET UPDATE STUD SET AND AVR<60.TA OF 600 AND PF OF 10% THEN CALCULATE THE NET SALARY. 2.NSAL THE CALCULATE HRA OF 12%.comparisonal operators.binary operator.*(mul). DIV=’SECOND’ WHERE RES=’PASS’ AND AVR>=50 DIV=’THIRD’ WHERE RES=’PASS’ AND AVR>=35 UPDATE STUD SET DIV=’NILL’ WHERE RES=’FAIL’. ex:. 2. = (equal) > (greater than) < (Less than) >= (Greater than or equals) <=(Less than or equals) != (or) <> :-Not equals Relational operators:a).SELECT * FROM EMP WHERE JOB NOT IN (‘CLERK’. CREATE A TABLE FOR EMPLOYEES WITH THE COLUMNS ENO.-(signs) 2.30).DA. e. 3.%:-Used for resembling the field values with a character. & :-Address operator used to refer the location of the variable or the field.unary(the operators deal with a single field) 2. UPDATE STUD SET SUB3<35. .used for comparing the field values with any others. operators:1.BASIC.g.binary opeartors:-the operators which deal with more than one fields or variables.

not between(opp. select * from emp where sal between 2000 and 3000. ex: 1. Where asc is used for ascending order and desc for descending order .BETWEEN:-Retrieves the data which lies in the range given by the between operator. c). ex:-select * from emp order by sal asc * from emp order by ename desc. syntax:-Select * from <<table name>> order by <<fieldname>> asc/desc. 2.Taking reference from one table to another table.SELECT * FROM EMP WHERE SAL BETWEEN 3000 AND 4000.preventing the insertion of duplicate rows into a column. ex:-SELECT * FROM EMP WHERE JOB LIKE ‘A%’.).SELECT * FROM EMP WHERE SAL NOT BETWEEN 3000 AND 5000. ORDER BY CLAUSE:This is used to retrieve the data from a table in ascending or descending order. . But the default order is ascending. ex:. NOT LIKE(Opp.LIKE:-Retrieves the data by using the meta characters(start letter. end letter etc. ex:-select distinct * from list. Retrieving the data based on an expression:-select * from table name where cname=&cname. to like) select * from emp where ename not like ‘A%’. 3.SELECT * FROM EMP WHERE ENAME LIKE ‘%S’. CONSTRAINTS:Constraints are the clauses by using which the following features can be added to a field of a table:1. ----selects the records from a table for which the rno entered satisfies. Distinct:-Used to retrieve only the distinct(not repeated) rows from a table. 3. 2.b). of between). SELECT * FROM EMP WHERE ENAME LIKE ‘%J__ES’.restricting the values with in a range. ex:-select * from emp where empno=&empno.

syntax:-column name dtype(w) constraints constr_name primary key ex:-rno number(3) constraints rno_c primary varchar2(10)).From the field to which primary key is associated. 4. More than once can be used in a single table.Only one primary key can be associated with a particular table. Basically Constraints are of two different types:a. reference can be taken to other columns of the same or different table.Not leaving a field as blank. syntax:-column name dtype(w) constraints constr_name check(condition). 2.not null:-Does not allow to insert null values to a column.unique:-This constraint designates a column as unique by means of which 1. null values can be inserted varchar2(10)). 4. syntax:-column name dtype(w) null ex:-create table con1(no number(3) NULL. name varchar2(10) constraints con_ck1 check(name=upper(name) and name like ‘P%’)). 5. In the above table no value can be entered into no column which are less than 100 and greater than 1000 and also no lower case . create table tab1 (no number(5) constraints con_ck check(no between 100 and 1000). reference can be taken to other tables from the column to which it is associated.check:-By using this constraint a column value can be restricted to certain range by giving a condition. Integrity constraints:1. Integrity constraints b.4. does not allow repeated values 3. ex:. Notes:1. More than one unique keys are allowed in a table. 3. syntax:-column name dtype(w) not null Ex:. Referential constraints A.create table con1(no number(3) not null.null:-allows to insert null values for a column which is a default property of a column. syntax:-column name dtype(w) constraint constr_name unique 5.primary key:-works as a not null constraint and also does not allow repeated values for a field .name varchar2(10)).create table con1(no number(3) constraints pk1 primary key .

sub3 number(3)).sub1 number(3). notes:1.For the referred column of the parent table there should be a primary key or a unique key.sub2 number(3).deptno number(2).ename varchar2(10) constraints emck1 check(ename=upper(ename)). create table depT1(deptno number(2) constraints de_pk primary holder’s name. 2.job varchar2(10).s3 number(3).sal number(7.s2 number(3). constraints emfk2 foreign key(deptno) references dept1(deptno)). • Create a table for transaction in the bank with the fields accountno.bal. .name varchar2(10).constraints stud3_fk1 foreign key(rollno) references stud(rno) on delete cascade). syntax:-<<col name>> dtype references <<table name>> (con name).s1 number(3). syntax:-Constraints <<c name>> foreign key(ref col name) references <t name>(parent col name). create table emp1(empno number(4) constraints empk1 primary key.closing bal to calculate the closing bal as per the tr type. mgr number(4) constraints emfk1 foreign key(mgr) references emp1(empno).tr type.foreign key:-Establishes a parent and children relationship between the tables by assigning a constraint name for that.The width of the reference column should be equal to the width of the parent column.div varchar2(6)).loc varchar2(10)). ex:-eno number(3) references emp(empno).hiredate date default sysdate. 7.comm number(4) null.references:-Used to refer a column of one table into another table or to another column in the same table.2) constraints emck2 check(sal between 800 and 5000).res varchar2(4). create table stud2(rollno number(3) references stud(rno).character can be entered for name and the name should start with the alphabet ‘P’.doj date)).dname varchar2(10) constraints de_uq unique. 6.The values available with the parent column only can be inserted to the column which is the reference. create table stud1 (rno number(3) references stud(rno). Ex:create table stud3(rollno number(3) constraints stud3_pk primary key. create table stud(rno number(3) constraints stud_pk1 primary key . 3.

Joining conditions:The procedure for combining more than one tables based upon a common data which shares the primary and foreign key relationship is called joining statements.sal.So to avoid this we have to . Adding a constraint:syntax:-alter table <<tablename>> add constraint <<con name>> con type(col name).sal number(7. constraints em_fk1 foreign key(mgr) references employ(eno). (To store the joined data in a table called empjoin) Outerjoin:In equijoin though we are selecting the data from dept table but all the data are not being retrieved . ex1:-Alter table stud add constraint st_pk1 primary key(rno).deptno=dept.job. Equijoin:Joining more than one table by basing upon a common field having primary and foreign key relationship and by using a (=) symbol is called equijoin.ename. create table empjoin as select empno.2) constraints em_ck2 check(sal between 2000 and 10000) empno.loc from emp.mgr number(4). ex2:-Alter table stud drop primary key. hiredate date default sysdate.constraints em_pk1 primary key(eno)).create table employ(eno number(4).selfjoin 4.dept where emp.sal. constraints em_fk2 foreign key(dno) references depart(dno).deptno=dept.alter table employ add constraints em_ck2 check(sal between 800 and 5000).ename. ex:. These are of 4 types:1. (Only for selecting) 2.deptno.Joining by using set operators.dept where emp.alter table employ drop constraint em_ck2 cascade.dname.job.dno number(2).equijoin 2.ename varchar2(10) constraint em_ck1 check(ename=upper(ename)). job varchar2(10).outer join 3.dname.deptno. ex:1.loc from emp. ex2:. comm number(7.2) null. Droping a constraint:syntax:-Alter table <<table name>> drop constraint <<con name>> cascade.deptno.

union all:-retrieves all the records from both the tables irrespective of the repetition. dname.union 2.5.7.dept d where e.use outer join. ex:-Select * from emp union all select * from employ1.e.5.ename. Selfjoin:If in a single table any column is referred from another column then those two can be joined by using a joining condition which is called the selfjoin.4.ename.4. The set operators are 1.deptno.2. ex:-select e.empno. Joining two tables by using set operators:Tables can be joined by using the set operators if they have the same m.2.6} B={4.d. Alias for table:If the name of a table is required as a subscription to identify a column then with out writing the full name a single letter can be used for that which is called the alias.e.8} a n b={4.5.e.emp.8} a ua b={1.4.8} a u b={1.3.mgr.sal. dept.m.e.3.ename.intersection 4.6.ename.2.job.8} union:-Retrieves the unique records from the two tables by combining those two.7.empno.7.sal.empno=m.dept where emp. ex:select * from emp union select * from employ1.e.e.3. d.e.m.deptno.deptno(+) =dept.job.2.mgr.6. .6.job.5.deptno=d.minus A={1.5. ex:.loc from emp e.dname.union all 3.empno.emp m where empno. This is possible by using a (+) symbol with the deficiency column in the joining condition.e.5. ex:.deptno.deptno.mgr from emp e.loc from emp.3} b-a={7.6} a-b={1.

Those are 1.Single row sub query. ex:select sum(sal) from emp. minus:-Retrieves only the rows from the first table except the rows which are common to both.s. . select * from dept. Generally these kind of query uses a * from emp where deptno=(select deptno from emp where job=’PRESIDENT’) ex-2:-select * from emp where sal>=(select avg(sal) from emp). ex:-select * from emp intersect select * from employ1. EX:.q. Single row subquery:The queries which retrieves only a single row are called s.simple query 2. etc. The maximum number of select commands can be taken in a nested query is 255. Queries are of three types. Select the details of the employees who are getting sal more than the avg sal of the employees from the department where president is working ? ex:-select * from emp where sal>=(select avg(sal) from emp where deptno=(select deptno from emp where job=’PRESIDENT’)).intersect:retrieves only the rows which are common to both the tables. ex:select * from emp minus select * from employ1. Simple query:-The statement used for selecting the rows from a table with a single select statement only is called simple query. sql queries:The statement which is associated with a select command is called a query.Nested query 3.r. ex:Select * from emp. Nested query:If in a single query more than one select statements exist one inside another then that is called a nested query. select avg(sal) from emp. Select * from emp where sal>(select avg(sal) from emp where deptno=(select deptno from emp where ename='SMITH')).

In a simple view if any changes made to either to the table or the view that affects both of those.job. ex:all:-Retrieves the rows which satisfies for the maximum value of the subquery as per the condition.job..simple view 2. ex:-select * from emp where sal>=all(select sal from emp where job=”manager”). Views:views are the logical windows to a table where data from one or more than one tables can be stored and retrieved.sum(sal) from emp group by job having sum(sal)>6000 Any/some and all operators:Any/Some:-Retrieves the rows for which the condition satisfies as the subquery returns. empdesig.. Retrieves all the records from emp where the sal is less than or equal to any of the sal(min sal) from emp where deptno=10.create or replace view empview as select * from emp where deptno=10.sal from emp where sal<=any/some(select sal from emp where job=’MANAGER’).. empsal) as select ename. 4.empno. . From a single table more than one views and from a view also another view can be created. 3.create or replace view empview(empname.job.max(sal) from emp group by job having max(sal)>=5000. ex:-1. 2.complex view 1.field2.simple view:-The view created from the datas of a single table is called a simple view. ex:-select job.empno. Retrieves all the rows from emp who gets sal more than the max sal of all the managers. ex:-select avg(sal).create or replace view empview as select empno.sal from emp.ename..ename.create or replace view empview as select * from emp. syntax:-Create or replace view <<view name>> as select field1. select job./ * from <<table name>>.deptno from emp group by by clause:used to retrieve the records from a table group by a field.sal from emp. ex:-select empno. Views are of two types1. having clause:This can be used with a group by clause to compare the value of a group function with any other values.

After creating a sequence it can be attached to one or more than one tables for generate the numbers as per the increment given.table2.dept where emp. syntax:-Create or replace view <<view name>> as select <<columns/ *>> from <<table1.. 1.loc. ex:create sequence s5 increment by 2 start with 1 maxvalue 20.nextval:-It generates the next value of the sequence as per the increment given.views with constraints:If a view is created with a where condition. syntax:-Create or replace view <<view name>> as select <<column names/ *>> from <<table name>> where <<condition>> with check option.ename .. ex:-create or replace view empv1 as select empno. notes:-Into complex views data can not be inserted because it’s based upon more than one tables.job.deptno from emp where deptno=20 with check option..sal. Complex view/Join view:-The view which is based upon the data of more than one tables or views is called a complex view. . So to prevent this type of insertion the view can be created with the constraint which is with check option. Sequences:Sequence is also a database object which generates the serial numbers with a step or the same numbers.deptno= dept.sal.currval:-It generates the current value of the sequence irrespective of the increment. syntax to create:create sequence <<sequence name>> increment by <<number>> start with <<number>> minvalue <number>> maxvalue <<number>> cycle/nocycle cache <<no>> /nocache.. ex:-create or replace view empv as select empno. job.dname from emp.ename.deptno. even then the rows can be inserted to that view which violates the where clause. 2. sequence parameters:To generate the numbers for a field the sequence should be attached to a table’s column by using the following parameters.>.

syntax:-create index <<index name>> on <<table name(column name)>>.&field2.). Clusters:This is a database object which stores some common data in a single space in the database based on a particular column which is called the cluster key. ex:-create index idx01 on stud(sno).&sub3). syntax:insert into <<table name>> values(<<seq.mgr).unique index 1.insert into st1 values(s3.field2. syntax:-create index <<index name>> on <<table name(field1.currval. 2. generates the numbers in the insert statements .&sub2.’&name’.Simple index:-Index based on a single field of a table. dropping a sequence:Drop sequence <<seq name>>.unique index:-Unique index just behaves like an unique constraint for a column. Ex:. By using this unnecessary wastage of memory space can be avoided.. altering a asequence:Alter sequence <<seq name>> maxvalue <<number>>. Index are of three types 1.simple index 2.while inserting it does not ask for the value of that column and it takes the value automatically from the seq.&sub1..’&name’. Indexes:Index can be created on a column or on more than one columns which is used to give the faster access to the user while retrieving the rows with a query using a certain condition based on that particular column where index is created.based on more than one fields of a table. ex:1. ex:-create cluster personnel(deptno number(3)).name>>. If already any repeated value is existing for a column for that the unique index can not be created.parameter. syntax:-create unique index <<index name>> on <<table(columnname)>>. 3.&sub1. ex:-create unique index idx1 on stud(rno)..attaching a seq to a column:The seq..multicolumn index 3.create index idx1 on emp(empno.&field3.…). 2.insert into stud values(s1.&sub3). .nextval.. It does not allow any repetition in the field values. S yntax:-Create cluster <<cluster name>> (clu_key datatype(width)).multicolumn Index:.&sub2.

1. . Creating new users:syntax:-Create user <<username>> identified by <<password>>.ename varchar2(10). This displays all the user lists existing.connect 2. An user is nothing but a privileged member who can access to the database. ex:-Grant connect/resource/DBA to maya. Displays the current user logged in. 1. which are of two types.create index cl_idx1 on cluster personnel.connect:-Grants the power to be connected to the database for the user. 2. These are just like the accounts. Now data can be inserted to the cluster tables e.DBA These privileges can be given by using the following data control language command:1.Resource 3.g. The privileges can be granted or taken off from the user in a user which is having the DBA privilege only. ex:. note:-In order to insert rows into the cluster tables we have to create a cluster index like syntax:-create index <<index name>> on cluster <<cluster name>>.So in order to create a user at first we should go for the system user. Each users will have one ID and all the Ids are associated with a password to open the user account. Select user from dual. 1.To use the cluster key in table we have to craete the table as follows:1)create table emp(empno number(3) . After creating the user they should have given functionality. which are called the privileges.though they deal with the database. 2)create table dept(dname varchar2(10).Database privileges :-The rights or privileges given to the user are called database privileges . to emp and dept. Privileges are the rights.deptno number(3))cluster personnel(deptno).Database privileges.deptno number(3))cluster personnel(deptno). syntax:Grant <<privilege>> to <<username>>. USERS:select * from all_users. Those are 1. A user can not be created in any other user except the system user unless until it has the DBA privilege .Grant:-Used to grant any of the privileges to an user.job varchar2(10).Object privileges. ex:-Create user maya identified by mehndi.

g.emp. . Grant succeeded.Resource:-Grants the power to create any object in the newly created user. Revoke:-This command is used to take out or withdraw any privileges from the user. SQL> select * from scott. view etc in it.g. resource etc like grant connect. Grant succeeded. 3. system user. Synonyms:These are just a duplicate copy for the tables in the same or different users. syntax:-create synonym <<synonym name>> for <<table name>>. syntax:-Grant insert/select/update/delete/all on <<object>> to <<user name>>.g the power to create user . Object privileges:-The privileges which can be granted to an object is called an object privilege. Those are insert. For that give the command:connect system/manager After creating the user give the required privileges e. ex:-Revoke connect.emp.resource to maya. select * from user. resource from maya. Now the user maya will be able to create any database objects like tables. SQL> grant select on emp to micro. All these are the commands that only can be given from the user which has the administration power e.2.grant and revoke the privileges etc. ex:-Create synonym s_emp for scott.delete and all. select . syntax:-Revoke <<privilege name>> from <<username>>. SQL> connect micro/mca Connected.If one table exist in scott user then a duplicate of that can be created in any other users by granting the object privillege to those.DBA:-Grants the data base administration privileges e. connect.object. Notes:-Before creating the user or granting any privilege first we have to go for the system user. update. SQL> show user user is “MICRO” SQL> connect Enter user-name: scott Enter password: ***** SQL> grant dba to scott.

lower:-Used to convert a string into lower case. Syntax:Create public synonym <<syn name>> for <<table name>>.Date functions 4.Numeric functions 3. Sql functions:Functions are the instructions which are allready created and initiates a particular action when called. Creating public synonym:This is a synonym which can be created in the user where the host table is present and from that synonym data can be accessed in any user present in oracle.These are of 4 types 1. output:-MICRO COMPUTERS b)select ename. 3.length:-used to find out the number of characters in a string. syntax:-length(‘string’/fieldname) ex:-select length(‘computer’) from dual. 3).If any changes are made in the table that reflects in the synonym and vice versa.upper:-used to convert a string into upper case letters. syntax:-initcap(‘string’/fieldname) ex:select initcap(‘micro computer associates’) from dual. 2. syntax:-lower(‘string’) ex:-select lower(‘MICRO COMPUTERS’) from dual.In synonyms it’s not possible to take ony a few columns from the table. dropping synonym: drop synonym <<syn name>>.initcap:-used to conver a string into it’s first character as upper case letter.If any previllege is granted or revoked from the table then it affects to the synonym. output:-Micro Computer Associates select ename. .lower(ename) from emp.Character functions 2. syntax:-upper(‘string’) ex:a)select upper(‘micro computers’) from dual.initcap(ename) from emp.upper(lower(ename)) from emp. note:-dual is oracles own table from where the datas not present in any table can be retrived.NOTES:1). 2).Conversion functions Character functions:1. output:-micro computers ex:-select ename. 4.lower(ename).

nos.4)from dual.’char2’).. 5.. 8.. Ex 1:-select * from emp where soundex(job)=soundex(‘CLERC’).’CLERK’. ex:-select instr(‘computer’.select job..nos. syntax:-concat(‘string1’. output:-mput 7.’char1’.translate(ename. syntax:-instr(‘string’/field name. syntax:-translate(‘string’.translate:-Used to replace a character in the string with any other char.length(ename) from emp.. 10. ex:-select concat(‘michel’.no of char).concat:-Used to add one string into another string’s end. 6. output:-A 13.. .’*’) from emp..b->98. ex:-select substr(‘computer’. syntax:-rpad(fieldname. syntax:-chr(num) ex:-select chr(65) from dual. 9. a->97.3..’old’. ex:-select ascii(‘a’) from dual.instr(ename. output:-97 12.substr:-displays only the number of characters given starting from a particular position.’s’) from emp.12. Syntax:-where soundex(field)=soundex(data).rpad(job. syntax:-substr(‘string’. output:-6 select ename.’*’) from emp.lpad:-Used to remove fill the leading blanks in a data from left.start no(POS)..’) FROM EMP.’string2’).replace(job.rpad:-used to fill the leading blanks in a char data from right.lpad(job. output:-corputer select ename.’char’) ex:..’char’).10. syntax:-ascii(‘char’). select ename..z->122 A->65.chr:-displays the char for an ascii number... ex:-select translate(‘computer’.’t’) fromdual.Z->90 0-48 . syntax:-replace (fieldname. 14.’new’) ex:-select job.job.ascii:-Used to display the ascii code of a char.instr:-Used to find out the position of a particular character in a string.’m’.replace:-Used to replace a data with another.output:-8 select ename.’char’) ex:-select job.Soundex():-Used to select the data from a table for a particular field for which it sounds as the data given.'XYZ') FROM EMP.job) from emp.9->57 11. Ascii(american standard code for information interchange.concat(ename.'ABC'.’r’) from dual. ASST. syntax:-lpad(fieldname.’JR..’jackson’) from dual.

15:-Ltrim:-To remove the space from a string from the left side.0) from emp. 11. syntax:-round(num. 8.index) ex:-select power(3. 9.user:-Returns the current user name logged into the system. syntax:-Abs(num) ex:-select abs(-345) from dual. ==>81 4. no of places to be rounded) ex:-select round(238.-select greatest(24.no2.any value) syntax:-select sal. syntax:-sign(field/num) ex:-select sign(sal-4000) from emp. Ex. 2. ==>345 3. of digits) ex:-select trunc( are 1.56 7.Ex 2:-select * from emp where soundex(ename)=soundex(‘myler’). syntax:-trunc(num.5678. 10.2) from dual.sign:-used to display the sign of a number value that whether it’s positive or negative.mod:-used to find the reminder of a division.43) from dual.5678.nvl:-Returns a value given for the null values while taking part in an operation. SELECT 'The employee '||ename||ltrim(‘ is getting Rs.57 6. ‘)||sal||’ per month’ from emp. .power:-returns the power of a number raised to a number.…. root of any number.sal+nvl(comm.trunc:-used to round off a number after cutting it to a certain position.round:-Returns the number after rounding off it upto certain digits. ex:-nvl(field.sqrt:-Returns the sq.7) from dual. Syntax:-greatest(no1. ==>238. syntax:-mod(num.divisor) ex:-select mod(45. output:-12 5. syntax:-power(num.abs:-Returns the absolute value of a number.).uid:-Returns the user id number from the table.2) from dual. Syntax:-ltrim(‘ string’). ==>45. greatest():-Returns the greatest of a set of numbers. syntax:-Sqrt(num) ex:-select sqrt(144) from dual. Numeric functions:The functions dealing with numbers is called numeric functions.no3.4) from dual.comm. Ex:-select uid from dual.56.

min(sal). ex:-select sysdate from dual. ex:-sum(field name) ex:-select sum(sal) from emp.sub2. Ex 2:-select job. Syntax:-least(no1. 2. syntax:-avg(field name) ex:-select avg(sal) fromemp. 3. 2.sum(sal).avg(sal). Syntax:-count(column name) Ex:-select count(empno) where of months) ex:-select sysdate.max/min:-returns the min or max of the field values. syntax:-max/min(sal) ex:-select min(sal) from emp.no3.sum:-used to find out the sum of a field values.add_months(sysdate. output:-23 14. Ex:-select least(23.last_day(hiredate) from emp.sub3.Sysdate:-Returns the current system date.month_between:-Calculates the months between two dates.10) from dual.sub2. syntax:-add_months(date. 15th may is saturday output:-21-may-99 5.count(sal) from emp group by job.hiredate) from emp. Least() :-Returns the smallest of set of any numbers. Date functions:1.56) from dual. output:-24 group numeric functions:1. syntax:-next_day(date. .ceil:-Returns the next whole of a decimal number.’21-dec-99’) from dual.5) from dual.sub2.last_day:-Returns the last day of the month. syntax:-months_between(date1.4) from dual.89. 3.avg:-returns the average of the field values.).….add_months:-Used to add any number of months in a date.66. select next_day(15-may-99’. 4.count():-Returns the number of data for each group. select max(sal) from emp.greatest(sub1.’day’) ex:-select sysdate.next_day(sysdate. syntax:-last_day(date) ex:-select hiredate.sub3) small from stud 13. syntax:-ceil(no) ex:-select ceil(23.sub3) great .least(sub1. etc.date2) ex:-select months_between(sysdate.max(sal).’friday’) from dual. select months_between(‘15-jun-99’. 4.346) from dual.next_day:-Returns the date for next appearance of the given day.no2. syntax:-floor(no) ex:-select floor(23. Ex:-select sub1.Floor:-Returns the integral part of a decimel number.12.

’format’) to_char(date.dd .converts the char value representing date into a date value according to the format specified.’day ddth month yyyy’) from dual.mon.to_date:. select to_char(sysdate.3rd mon 3 letter format(jan.to_char: converts number or date to character format . 2nd.’ddth month yyyy hh24:mi:ss’) from dual.’fmt’) ex:-insert into emp(hiredate) values(to_date(‘11/11/2001’. ex:-select sal. RM Returns the number with roman format.yyyy’) from dual. last digit of the year last two digits last three dig full year In character format like (two thousand two) time in 12 hours time in 24 hours minutes seconds am/pm am/pm with (.’date picture’) codesuse day monday d 1-7 dd date of the month dy Day of the weak in 3 chars.(e.) ex:-select to_char(sysdate.999 Separates the thousands place with a comma. Number formats:Format Use 99.feb) month full month mm 1-12 y yy yyy yyyy year hh hh24 mi ss am a. syntax:-to_char(date/number.…) ddth date with the abbr.’dd mm yy’)from dual. 2. select to_char(sysdate.5th. syntax:-to_date(‘char’. $9999 Displays the number with a leading dollar($) Symbol 9999MI returns a (–) sign to the end if a negative number.’dd/mm/yyyy’)). conversion function:1.’mm .g last_day(sysdate) from dual.999’) from dual. select to_char(sysdate.’$99.m.to_char(sal. if the format is omitted form is dd-mon-yy. .

prompt:-To display any text on the screen.changed value with expr) ex:-select sal. c)save file append :-To add another command to an already existing command file. Syntax:.edit filename 5.999’ column ename format a4 column ename HEADING ‘EMPLOYEE|NAME’ Concatenation operator:- . SQL*PLUS:This is the main software of oracle which checks and keeps track on all the activities of oracle applications.ex2:-insert into dd values(to_date(‘08-25-2002’.5/100) from emp.column:-Used to get various effects with the columns of a table.Decode:-used to change the values for a certain field based upon another field of a table.job.describe:-Used to describe the database structure of a table. • >increases the sal by 1.define:-Used to display the value stored in a variable. syntax:-decode(field.decode(job.5% for managers.accept:-Used to accept a value for a variable .save:-To save a command in a file with the extension . It has some commands which are:1. syntax:-Accept varname prompt “Any text :” hide ex:accept rollno number prompt “Enter the rollno :” accept pawd char prompt “Enter password :” hide 9. Syntax:-Desc tablename 6. column sal format ‘$9. Syntax:-column <<c name>> heading/format <<new heading /format>> Ex:column empno heading eno column sal heading salary etc.’mm-dd-yyyy’)) 3.edit:-Used to open a file in the notepad buffer.sql syntax:a)save filename b)save filename replace:-To replace the content of a command file with another command. Syntax:-prompt string 8.’value of the field’.quit/exit:-To close oracle sql*plus. 2. Syntax:-define variablename 10. 3. 7.sal* scr:-To clear the screen.’MANAGER’. Syntax:-@filename 4.@ /start:-To execute a command file.

Set feedback off/on:-Does not display any feedback after the execution of the command.pnoskip 1 center ‘For Year –2001’ .right 3. These titles can be given in 3 alignments those are 1.pagesize.Show:-Used to show various options like user. Set time on/off :-Displays the current time as sql prompt.left 2. Set sqlprompt “text” :-To change the sql prompt to any text. 12.underline.Select ‘The employee ‘||ename ||’ is drawing Rs.user :-for the user name who is logged in currently. etc syntax:-show <<options>> 13. 2.pagesize.Setting title for a table:Titles are of two types.pno :-For current page Sql.lno :-for current line Sql.TTITLE LEFT “EMPLOYEE REPORT” CENTER “MICRO COMPUTERS” RIGHT “PAGE:” SQL.numwidth etc. 14.btitle:-Stands for the bottom title.rephead center “ANNUAL REPORT-2001” repfoot center “END OF THE ANNUAL REPORT” ex:ttitle left ‘Sathyam Infoways’ center ‘Employee Reports’ right ‘Page :’ sql.set:-used to set linesize.’ ||sal||’ per month’ from emp. syntax:ttitle/btitle left/right/center “title” Some sql defined columns also can be used like Sql.Clear column:-To cancel the column commands.Report header and footer:Report header is a message which appear at the top of the report and report footer which appears at the end of the report.PNO 15. Syntax:Rephead/repfoot “any message” Ex:.linesize.ttitle:-Stands for top title. Ex:1. syntax:-set <<option>> set underline <<char>> set underline off/on set heading off/on set timing on/off :-Displays the time taken for the execution of a command. 1.TTITLE “EMPLOYEE REPORT” 2. a title which appears at the top of each page. a title which appears at the bottom of each page.

Syntax:Skip page or skip <<no of lines>> 16. syntax: break on <<cname>> 17. which can be called at any moment it required. 4.” ttitle “Data for 2002” break on deptno skip 1 compute sum of sal on deptno select * from emp order by deptno.break:-used to break a particular column. Syntax:Input Command 1 Command 2 ………….16. 3. Features of pl/sql are:1. syntax:-clear columns/break/compute etc.Skip :-Used to move the control to any no of lines or a page forwards. PL/SQL(procedural language ext. packages.Though it’s an extension to SQL it supports almost all SQL commands. 2.avg. 19.Any statements can be repeated in the execution by using the loops. ………… save filename input rephead “Employee Info. 5.It supports the programming feature by using which more than one statements can be combined together to perform a particular task. triggers etc.input:-Used to accept more than one SQL*PLUS commands as a single one and can be saved as a command file. 18..It ‘s most important feature is it allows the user to create stored program units like procedures. to SQL):Though It’s a procedural language it supports programming features.It allows the user to take decisions by using the if else statements. .max of the field values at each breaks. functions. Syntax:-compute <<opt>> of <<field>> on <<break column>> ex:break on deptno skip page compute sum avg min max of sal on deptno select * from emp order by deptno.compute:-Used to calculate the sum.clear:-used to clear the formats or column attributes applied to the fields or tables.min.

put_line(‘roll no=’ || rno). syntax:var:=&var name. name varchar2(10). name:=’&name’. Which can be written as the following syntax:declaration section Begin execution part <<input statements arithmatical statements output statements>> exception handler section end. --(used for comments) .Every plsql prog. Arithmetical statements:Statements used for calculation var:=var (o) var. etc. input statements:The statement required to enter the data to the variables is called in put statement. dbms_output.put_line(var name). tot:=sub1+sub2+sub3. -->to print the string dbms_output. Note:-“ ||(concatenation) “ is used for combining two strings or values. dbms_output. declaration sec:-In this section all the variables which is to be used in a prog. ex:-rno number(3). Note:-While assigning values to variable the “ : “ should be used before the assignment operator(=) e. etc. ex:sum:=no1+no2.put_line(‘welcome to pl/sql’).put_line(‘Any string’). etc. --> to print the value in a variable ex:dbms_output. ex:-rno:=&rollno. synt:var datatype(w). is called the combination of statements or more than one blocks. set serveroutput on:-Used to make the output console open. And these variables are called bind variables. output statements:The statement used for getting the output .g (:=). should be declared as their types.

dbms_output.put_line(‘Reminder=’||rem). end.put_line(‘Quotient=’||q).put_line(‘Product=’||p). s:=no1+no2. set serveroutput on begin dbms_output. d:=no1-no2. begin dbms_output. d number(5). dbms_output. p:=no1*no2.2).put_line(‘Second number=’||no2).6. dbms_output.put_line(‘============================’). begin no1:=&number1.put_line(‘First number=’||no1). no2 number(5). dbms_output. rem:=mod(no1. end. • initialization of variables no2 number(3. p number(8). q number(7. rem number(3).put_line(‘============================’). dbms_output.• • prg1:WAP to print any statement. product. no2:=&number2.put_line(‘Sum=’||s). dbms_output. s number(5). difference. dbms_output.put_line(‘Difference=’||d). • WAP to enter any two numbers and find out their sum. dbms_output.no2).1):=5.put_line(‘Wel come to Pl/sql programming’). quotient and reminder. set serveroutput on declare no1 number(5). • WAP to print any two numbers set serveroutput on declare no1 number(3):=100. q:=no1/no2. . end. / • WAP to find out the total and average of 3 sub marks for any student.

sub3:=&sub3.put_line(‘Total marks=’||tot).put_line(‘Sub2 marks=’||sub2). rad number(5. begin rad:=&radius. sname:=’&stud_name’.set serveroutput on declare rno number(3). end. set serveroutput on declare pi number(5.141. / • WAP to accept the principal amount. dbms_output. dbms_output. sub1:=&sub1.put_line(‘Average marks=’||avr).put_line(‘Roll no=’||rno). sname varchar2(10).put_line(‘Sub3 marks=’||sub3).put_line(‘Stud name=’||sname).’).put_line(‘ ‘).’). area:=pi*rad*rad. Cms.put_line(‘Circumference=’||circum||’Cms. dbms_output. dbms_output. sub3 number(2). dbms_output. dbms_output. area number(7. end. dbms_output.’). rate and time period then find the simple interest and also find the amount to be paid by the bearer. avr:=tot/3. sub2:=&sub2.2). sub2 number(2).put_line(‘Area=’||area||’Sq. dbms_output.2).3):=3.put_line(‘Radius=’||rad||’Cms. sub1 number(2). begin rno:=&rollno. / . dbms_output. circum number(7. dbms_output. avr number(5.2). tot:=sub1+sub2+sub3. dbms_output.2). • wap to find out the area and circumference of a circle. circum:=2*pi*rad. tot number(3).put_line(‘Sub1 marks=’||sub1).

else statements for false. else statements for false. . end if. / IF ELSE STATEMENTS:Unlike other softwares in pl/sql also it’s possible to take decission by using the keywords “if” and “else”.2).sal. s number(7.job into en. end if. dbms_output.The keyword if is allways associated with a condition and if the condition satisfies then the statements following it executes.S.x from emp where job=x. set serveroutput on declare x varchar2(10). select ename.• WAP to enter any roll number and print the corresponding name from emp table. . begin x:=’&job’.put_line(‘Job=’||x||’ ‘||’emp name=’||en||’ salary=’||s). . syntax:if condition then statements for true. • wap to find out the greatest of any two numbers soln:set serveroutput on declare no1 number(5). for more than one choice:if cond1 then statements . en varchar2(10). no2 number(5). end. begin no1:=&number1. elsif cond 2 then statements.

else dbms_output. Totsal:=msal+bonus. if num>0 then dbms_output. Annsal number(9.2).2):=&msal. • WAP to accept the monthly salary of any employee and the find the bonus of 12% on annual salary if experience is more than 3 years and otherwise the bonus is Rs. begin num:=&number. end. • WAp to enter any number and find out whether it’s positive or negative or zero.After all calculate the total salary received by the employ on that month along with the bonus amount. else dbms_output. Totsal number(9. end.put_line(no2||’ is greatest’).2). Exp number(3). elsif num<0 then dbms_output. set serveroutput on declare num number(5).2).put_line(num||’ is positive’).1000. End if. Annsal:=msal*12. if no1>=no2 then dbms_output.no2:=&number2.put_line(num||’ is equal to zero’). end if. Declare Msal number(7. Begin Exp:=months_between(sysdate. . Else Bonus:=1000. If exp>3 then Bonus:=annsal*12/100. doj date:=’&date_of_join’. end if.doj)/12.put_line(no1||’ is greatest’).put_line(num||’ is negative’). Bonus number(7.

Dbms_output.put_line(‘Experience=’||exp||’ years’).put_line(no||‘ is mutiple of only 3’). Begin If mod(no.’||totsal). / .put_line(‘Bonus amount=Rs. end if. end. Dbms_output. end if. Dbms_output. end if. else dbms_output.This is required when we need to combine more than one conditions.5)=0 then dbms_output.put_line(no||‘ is mutiple of only 5’). • WAP to accept any number and check whether that is a multiple of only 3 or only 5 or both 3 and 5 or none of them.’||bonus). Syntax:if cond1 then if cond 2 then Statements Else statements end if.Dbms_output. else if mod(no.3)=0 then If mod(no.put_line(‘Total salary drawn=Rs.5)=0 then dbms_output. / Nested if-else:If one condition is written inside another condition then that is called nested if-else.’||annsal). Declare No number(4):=&no. else dbms_output. else if cond3 then statements else stements end if.put_line(no||‘ is mutiple of both 3 and 5’). End. end if.put_line(no||‘ is mutiple of none of 3 and 5’).put_line(‘Annual salary=Rs.

end if.res=re. else d:=’nill’. a number(5. re varchar2(6). s1 number(2). d varchar2(8). end if. elsif re=’pass’ and a>=50 and a<60 then d:=’second’. s2 number(2).avr=a. select sub1. begin r:=&rno. if re=’pass’ and a>=60 then d:=’first’. if mod(num. set serveroutput on declare num number(4). t number(3). else re:=’fail’.2). a:=t/3. end. s3 number(2).declare r number(3). end if.2)=0 then dbms_output. if s1>=35 and s2>=35 and s3>=35 then re:=’pass’.put_line(num||’ is even’).sub3 into s1. • wap to input any number and check wheather it’s even or odd. t:=s1+s2+s3. end. • WAP to find out the greatest of any three numbers.sub2. elsif re=’pass’ and a>=35 and a<50 then d:=’third’.s2.s3 from stud where sno=r.put_line(num||’ is odd’). begin num:=&number. else dbms_output. set serveroutput on declare .div=d where sno=r. update stud set tot=t.

3)=0 then dbms_output. end. if mod(num. no3:=&number3.3)=0 and mod(num. end if. no2:=&number2.put_line(no2||’ is the greatest’). else dbms_output.put_line(no3|| ‘ is the greatest’). if no1>no2 and no1>no3 then dbms_output. else dbms_output.put_line(num||’ is neither multiple of 3 nor of 7’). elsif no2>no3 and no2>no1 then dbms_output. begin ch:=’&char’. end.7)=0 then dbms_output. begin no1:=&number1. end if.put_line(no1||’ is the greatest’). / • WAP to enter any number and check wheather it’s a multiple of 3 or 7 or both 3 and 7 or not of 3 or 7. no3 number(4). begin num:=&number.put_line(ch ||’ is a vowel’).7)=0 then dbms_output. / • WAP to enter any alphabet and check it wheather it’s a consonant or a vowel.put_line(ch|| ‘ is a consonant’).put_line(num||’ is multiple of both 3 and 7’). else dbms_output. declare ch varchar2(1). no2 number(4). .put_line(num||’ is multiple of only 7’).no1 number(4). if ch=’a’ or ch=’e’ or ch=’i’ or ch=’o’ or ch=’u’ OR ch=’A’ or ch=’E’ or ch=’I’ or ch=’O’ or ch=’U’ then dbms_output.put_line(num||’ is multiple of only 3’). set serveroutput on declare num number(5). elsif mod(num. elsif mod(num.

price.2). update cust set tot=t. • wap to findout tot .2)). / create table cust(cno number(3). . syntax:initialisation of loop variable x:=1.dis=d.qtytaken number(4).dis and billamount in the above prg. loop statements.&qtytaken). t number(8. Those are generally of 4 types:1.2). else d:=1. net number(8.dis number( qty number(4). if t>10000 then d:=2. pr number(7. end. declare cn number(3).for loop 4.billamt=net where cno=cn.’&itemname’.itemname.billamt number(8.2). net:=t-d. x:=10. end. d number(6.qtytaken) values(&cno. end if. / Loops:Loops are used to repeate the execution of a statement for more than once in a programme. t:=pr*qty.2). where dis=2.while loop 3.itemname varchar2(10).5%.2).2). select cno.tot number(8.5*t/100.price number(7.5% if tot>10000 otherwise dis=1. insert into cust (cno.qtytaken into cn.price. begin cn:=&cust_number.qty from cust where cno=cn.&price.5*t/100.simple loop 2.end if.cursor for loop Simple loop:-This loop starts the repetition according to initial value given to the loop variable and continues till the exit statement encounters it.2).

begin x:=1.increment/decrement. set serveroutput on declare x number(2):=1. • WAP to to print a string for 10 times. end loop. begin n:=&number. if x>10 then --if x<1 then exit. loop t:=n*x. begin loop dbms_output. (if <<condition x<=10/x>=1>> then exit. end. ((or)) exit when condition(x>10).) end if. end loop. --x number(2):=10. t number(5). x:=x+1. end loop. exit when x>10.put_line(‘Welcome to loops’). x:=x+1. n number(4).put_line(x). . end. / • WAP to print the number 1 to 10 set serveroutput on declare x number(2).put_line(n||’*’||x||’=’||t). exit when x>10. x:=x+1. end loop. --x:=x-1. dbms_output. x:=x+1. x:=x-1. loop dbms_output. / • WAP to print the table of any number declare x number(2):=1. end if.

/ • WAP to print the numbers from 1 to 30 with alternate difference of 3 and 4. declare x number:=1.5 in decreasing order. declare n number(3). end if. begin n:=&number. elsif d=4 then d:=3.5. 1 4 8 11 15 18 22 25 29 declare x number:=1. end. end if.put_line(x). --WAP to findout the factorial of any number. exit when x>30. elsif d=4. x number(2):=1. end loop. if d=3. d number:=3. if d=3 then d:=4. exit when x>40.5. x:=x+d. end loop. / • WAP to print 40 to 1 with an alternate difference of 3.5.5 then d:=4. begin loop dbms_output. x:=x+d. .5 then d:=3. f number(5):=1.5 and 4. end.put_line (x). begin loop dbms_output. end. d number:=3.

put_line(‘Factorial of ‘||n||’ is=’||f). t:=floor(t/10). begin n:=&number. loop r:=mod(t.e even or odd) . n:=t. end loop. dbms_output.put_line(‘reverse of ‘||n||’ = ‘||s). end loop. exit when t=0. / For loop:syntax:for <<var>> in startno. t number(4). end. / / --WAP to findout the reverse of a number and sum of the digits of a number. dbms_output. r number(4). declare n number(4).put_line(‘Sum of the digits of ‘||t||’ = ‘||s).10). end. t:=n. --WAP to print the numbers from 1 to 10 and print the numbers with their type(i. exit when x>n.. loop r:=mod(n. s number(4):=0.endno loop statements. n:=floor(n/10). x:=x+1. end loop. exit when n=0. dbms_output. end loop. s:=s+r.10).loop f:=f*x. s:=s*10+r. s:=0.

put_line(n||’ ‘||t).. r number(2). end if. for i in 1..+n*n declare n number(5). begin n:=&number.. dbms_output. sum=1*1+2*2+3*3+4*4+.declare n number(2). begin dbms_output. s number(5):=0. t varchar2(5). for n in 1.10 loop if mod(n. end... s number(6):=0. n1 number(4).. begin n:=&number. loop exit when n1<1.2)=0 then t:=’even’.put_line(‘The sum of the series=’||s). n1:=n. dbms_output. end loop. i number(3). . end loop.n loop s:=s+(i*i). else t:=’odd’.put_line(‘Number’||’Type’). end. / --WAP to find out the sum of the squares upto any number starting from 1. / Armstrong numbers:Sum of the cubes of the digits of the number=num 153=1*1*1+5*5*5+3*3*3=>1+125+27 set serveroutput on declare n number(5).

no:=sql%rowcount.implicit cursor:-The cursor which is created by the oracle buffer automatically where any dml statements encounters to a table.put_line(n||’is armstrong’). n1:=floor(n1/10). Those are:1. end if. --wap to delete the data for employees after entering the job.Explicit cursor:-this is the users private area Where data can be collected from a table and can be accessed. A cursor supports 3 attributes to work with it.put_line(‘Some data has been retrieved by the cursor’). 2.3).10).sql%found:-Returns a true value if the cursor retrieves any rows from the table. end if. / --WAP to increase the sal of employees by 1000 rs.sql%rowcount:-Counts the number of rows retrieved by the query.r:=mod(n1. elsif sql%found then dbms_output. Cursors:It’s an area where data can be selected and accessed either by oracle or the user. end. s:=s+power(r. if sql%notfound then dbms_output.sql%notfound:-Returns a true value if the cursor does not find any value in the query. begin delete from employ where job=’&job’. if s=n then dbms_output. else dbms_output. 2. begin . 3. end loop.put_line(n||’is not armstrong’). declare no number(3).put_line(‘There is no employee doing this job’).put_line(‘No of records deleted=’||no). dbms_output. for deptno=10. There two types of cursors:1. end. set serveroutput on declare x number(4).

if sql%found then dbms_output. of row updated’).update emp set sal=sal+1000 where deptno=&deptno. end. name varchar2(10) not null :=’ ‘. end if.put_line(‘Some rows are retrived by the query’). m varchar2(30).put_line(‘query is not able to retrive any row’).deptno number(3).put_line(x||’ no.put_line(x||’ no. time varchar2(10). elsif sql%notfound then varchar2(10)). / set serveroutput on declare x number(4). / --WAP to increase the salary for the employees of a particular department and enter the no of records create table cursor_ret(mess varchar2(30). / set serveroutput on declare x number(4). of row updated’).time. dbms_output. x:=sql%rowcount. x:=sql%rowcount. of row updated’). dbms_output. t char(6).update_date date. set serveroutput on declare x number(4).put_line(x||’ no. x:=sql%rowcount. . dbms_output. begin update emp set sal=sal+1000 where deptno=&dno. D NUMBER(3). begin delete from emp where job=’&job’. end.dept no and name of the person who increased the salary into another table called cursor_ret. end.

ename varchar2(10).2). name varchar2(10).’hh24:mi’). j varchar2(10).to_date(sysdate).job varchar2(10). There are 4 main parts in a cursor which are:(declaration of a cursor:cursor <<cur name>> is select <<field names>> from table name <<cond>>. salary number(8. cursor c1 is select empno.job. / Explicit cursors:-This is the oracles private area which can be created by the user. name:=’&your_name’.D. clerk table:create table cl_table(empno number(4).‘query is not able to retrieve any row’). After the creation data from a database can be selected into the cursor. ex:-fetch c1 into eno. (closing the cursor:close <<cur name>>. sal number(8.put_line(‘Some rows are retrieved by the query’).begin D:=&DNO. ex:-close c1. of row updated’). ---WAP to insert the datas of the clerks from emp table to another table . if sql%found then dbms_output.ename.put_line(x||’ no. dbms_output. ex:-cursor c1 is select empno. x:=sql%rowcount. (opening a cursor:open <<cursor name>>. insert into cursor_ret values(m. begin . end if.deptno from emp where job=’principal’. (fetching the data from the cursor to the bind variables:syntax:-fetch <<cursor name>> into <<variables>>.deptno number(3)).name). dno number(3). m:=concat(to_char(x). ex:-open c1.sal.ename.sal from emp where deptno=10. t:=to_char(sysdate.’ no of rows updated on ‘). elsif sql%notfound then dbms_output. declare eno number(4).t. update employ set sal=sal+1000 where dno=D.salary.

totsal number(9. loop fetch c1 into eno.totsal)values(‘Dept 20 total salary :’.salary.put_line(‘Dept 20 total salary :’||tot2).totsal)values(‘Dept 10 total salary :’. cursor c1 is select sal. end loop. s number(6).deptno from emp.tot2). set serveroutput on declare tot1 number(6) c1.dno . insert into temptot(chcol. elsif d=30 then tot3:=tot3+s. end if.j. insert into temptot(chcol. create table temptot( chcol varchar2(40). / • WAP to calculate the total salary for each deptno of the emp table and put those into another table. if d=10 then tot1:=tot1+s. exit when c1%notfound. insert into temptot(chcol. end.tot3). begin open c1. dbms_output. tot3 number(6):=0. close c1. dbms_output. end.2)). dbms_output.salary.put_line(‘Dept 30 total salary :’||tot3). elsif d=20 then tot2:=tot2+s. / cursor for loops:This is a kind of loop which executes the number of times till the cursor retrieves the last record of the table. close c1. end loop.d.totsal)values(‘Dept 30 total salary :’.dno).name. exit when c1% notfound. . tot2 number(6):=0. insert into cl_table values(‘Dept 10 total salary :’||tot1). loop fetch c1 into s. d number(4).tot1).j.

cmr) values(105.2360.421).mrent 150 charged unit >400 rate=4.pmr. bill:=tamt+mr. insert into apseb( number(4).’eee’.35*100+(cunit-100)*2. end if.cmr) values(104.cname.2278). if cunit<=100 then tamt:=1.35+300*2. insert into apseb(cno.cmr from apseb.2)).’bbb’.95.2).pmr.pmr.cname.3278).cmr) values(101.mrent 200 create table apseb(cno number(3). WAp to calculate the electricity bill for apseb with the conditions:if charged unit<=100 rate=1. end.2). • insert the records:insert into apseb(cno. mr:=100.360.cmr-i. update apseb set number(7. bill number(8.1278). mr number(3).cname.’aaa’.mrent number(3).35. pmr number(4).cname. elsif cunit>400 then tamt:=100*1.cname varchar2(5).256.5.netbill number(8. elsif cunit>100 and cunit<=400 then tamt:=1. mr:=150. tamt number(7.cmr number(4).pmr.cmr) values(103.cname.pmr. mr:=200.cmr) values(102.syntax:declaration of the cursor begin for var in <<cur_name>> loop statements end loop.2010.mrent=mr. cunit number(4).35*cunit. end loop. / • . insert into apseb(cno.mrent 100 charged unit >100 rate=2.95.’ddd’. declare cursor c is select cno.pmr. begin for i in c loop cunit:=i.3228).pmr.cno.’ccc’.total=tamt.2). insert into apseb(cno.netbill=bill where cno=i.95+(cunit-400)*4.3160.

s number(8. syntax:exception when too_many_rows then action.sub2. end. 1. sql>create table empl as select empno.• WAP to calculate tot and average of students for three subjects by using cursor for loop.deptno from emp . t number(3). sql>truncate table empl.2).err_type varchar2(50)).2).Dup_val_on_index etc.avr=a where sno=i. sql>create table error_tab(eno number(6). / Exceptions:If in a pl/sql programme any error encounters then the exceptions are used to control and handle those. . begin for i in c1 loop t:=i.too_many_rows:-This exception occurs if the select statement retrieves more than one rows when the user need only one.sub2+i.sub3. a number(5. i number(3). update stud set tot=t. • WAP to accept any employee no. The exceptions are of different types those are:1. end loop.when_no_data_found 2. and insert the existing data into another table. declare e number(6).sal.job. n varchar2(10).sno from stud.ename. Write the exceptions such that if any error encounters then the empno and a message should be inserted to another table called error_tab.sno.sub1+i.sub3.Too_many_rows 3. declare cursor c1 is select sub1. a:=t/3.

d). n varchar2(10).job.j.n. insert into temp1 values( begin e:=&empno.sal.d number(2).s.’There are no rec with this no. d number(2). name varchar2(10).2). end. exception when too_many_rows then insert into error_tab values(e. end.j.d). begin e:=&empno.j. j varchar2(10). s number(8. dup_val_on_index:-This error occurs when a duplicate value is entered into a column having unique index or primary key.deptno into n.’). j varchar2(10). l:=’&location’.job. select ename.d from emp1 where empno=e. l varchar2(10).err_type varchar2(20)).sal. select ename. declare e number(4).n.l).’).j. when no_data_found then insert into error_tab values(e. exception .deptno into n.’Width of the field exceeds the limit’). insert into dept values(dno. set serveroutput on declare dno number(2).d from emp1 where empno=e. insert into empl values(e. / Note:-Value_error occurs if the width of a field exceeds while entering the value.s. / create table err_tab(eno number(4). name:=’&dname’. begin dno:=&deptno. • Wap to enter the data to dept table by using exception such that it should not display any error if duplicate deptno is inserted.’There are more than one rec with same no.s. when value_error then insert into error_tab values(e.

when <<exception name >> then action. insert into error_tab values(no. s1 number(3):=&sub1.when dup_val_on_index then insert into error_tab values(dno.’Record already exist’). . xyz exception. s3 number(3):=&sub3. sname varchar2(10):=’&name’. / .s3). / declare no number(3):=&rollno. end. syntax:declare excep_name exception. if cond then raise <<exception name>>.s2. end if. end.sname.put_line(‘Sorry . s2 number(3):=&sub2. begin .put_line(‘Record allready exist’). / User defined exceptions:These can be defined by the user in the declaration section and can be used in the plsql block. end if.s1. else insert into stud values(no. .’Sorry mark can not be greater than 100’). end. begin if s1>=100 or s2>=100 or s3>=100 then raise xyz. dbms_output.U can not enter marks more than 100’). exception when xyz then dbms_output.

2). end if. name varchar2(10).2).0). b number(7. name:=’&ahname’. w number(7.ename varchar2(10).Attributes are of 2 types:1. • WAP to calculate hra. else update bank set cbal=(b+d)-w where 2.da. insert into bank values(ano. .column%type:-Declares a field as a column type from any oracle table. exception when my_exp then insert into err_tab values(ano.ahname varchar2(10).ta.2). my_exp exception.ex:drop table bank. sal number(7.d. begin ano:=&accno.ta number(6. / Attributes:By using the atributes the columns and rows can be declared by any other columns or rows from an existing table.2).hra number(5.dep number(7. create table bank(acno number(3). b:=&bal.2).w.2). end. pbal number(7.’insufficient balance’).2). if (b+d)<w then raise my_exp. d number(7.wit number(7.2). cbal number(7. This acts as the data type in the pl/sql blocks.row%type:-designates the variable as a row type from any valid oracle table.2)). w :=&wit_amt. create table empl(eno number(3).b.2).da number(6.2). d:=& drop table empl. declare ano number(3).net for employees based on basic sal.

sal) values (101.ename. no number(5. job varchar2(10). s empl.da=d.’ddd’. x number(4). h empl.sal.8000).deptno from emp.ta%type.’aaa’.s. create table empl2 as select empno.ename varchar2(10). sal number(8. insert into empl (eno.2)). WAP to select the datas of any employee from empl2 table and insert it to another table called empl1. exit when number(8.sal) values (104.’bbb’. p:=s*10/100.dno number(2)). loop if c1%isopen then fetch c1 into no.5000). n:=(s+d+t+h)-p.eno%type. declare emp_rec empl2%rowtype.ta=t. n empl. declare cursor c1 is select d:=s*25/100.’ccc’. begin x:=&empno.da%type. close c1.sal) values (103. create table empl1(eno number(4). insert into empl (eno.2).3500). insert into empl ( where eno=no.job. . d empl. update empl set hra=h. / syntax for rowtype:rec_name(any var) table%rowtype. t from empl. select * into emp_rec from empl2 where empno=x.sal) values (102.6500). end loop. h:=s*13/100. end. insert into empl (eno.ename. end if. p empl. drop table empl1. t:=800.2). begin open c1.

ename) values(no.insert into empl1 values(emp_rec. begin statements end. Executing a procedure individually:exec <<procedure name>>(arg1... end. / Calling a procedure by using the programmes:set serveroutput on declare x number. end.y). dbms_output. / create or replace procedure input_rec(no number.).deptno).no2 in number) as s number.arg2.job.emp_rec. y number.sal. syntax:create or replace procedure <<pro_name>>(argument lists) as/is declaration of the varchar2) as begin insert into empl (eno.emp_rec.ename.emp_rec.empno.e mp_rec. end. / . end. begin s:=no1+no2. pro_add(x. / Procedures:Procedure is a pl/sql programme unit which will be stored permanently if created once then they can be called by their names several times when required. Create a procedure for adding any two numbers:create or replace procedure pro_add(no1 in y:=&num2.put_line(‘Sum of the two numbers=’||s). begin x:=&num1..

create or replace procedure update_emp(no number. p where eno=no. p:=10*s/ number) is h empl. p:=10*s/100. t:=8*s/100. d:=25*s/100. d:=23*s/100.exec exec exec exec exec input_rec( t empl. t:=800.’ccc’). e number. t:=1000.da%type. j varchar2(10). p:=10*s/100. / create or replace procedure addemp as cursor c1 is select * from empl2 order by empno. s number.da=d.’eee’).’ddd’).pf%type. / create or replace procedure delete_emp(no number) as begin delete from empl where eno=no.’bbb’). d empl. end. update empl set sal=s. d:=21*s/100.ta=t. else h:=15*s/100. end.’aaa’). input_rec(104.ta%type. end if. n empl.hra=h. na varchar2(10). . d number. begin if s>=10000 then h:=12*s/100. input_rec(103. input_rec(105. elsif s>=5000 and s<10000 then h:=14*s/100. n:=(s+h+d+t)-p. input_rec(102.

end.s. create or replace function funadd(no1 in number. create a function for adding any three numbers.s.. begin s:=no1+no2+no3. end loop. loop fetch c1 into e.d .na. Unlike procedures they can not be called individually by using the execute open c1.c). / . no2 in number. begin x:=funadd(a. b number(3):=&no2. end.. syntax:create or replace function name(arg1 dtype. begin statements return var. c number(3):=&no3.put_line(‘Sum of three numbers= ‘||x). exit when c1%rowcount>5. / Functions:These are also the stored programme units which can be created and called any where in any other programs .j.d).) return dtype is/as declaration of variables. close c1. dbms_output. end. return s.j. Generally the function returns a value. insert into empl1 values(e. / • prog to call addfun:set serveroutput on declare a number(3):=&no1.no3 in number) return number is s number.arg2 dtype..b. x number(5). end.

end loop. create or replace function funfact(no in number) return number is x number:=1. dbms_output. / • crteate a function to find factorial of a number. end. return f. / declare n number. begin while x<=no loop f:=f*x. begin select hiredate into Hdate from emp where empno=eno. begin n:=&numbe. begin s:=funadd(100. / declare e number(4).300). . f:=funfact(n). dbms_output. f number. return hdate.200. create or replace function funhire(eno in number) return date is hdate date. end.declare s number. end. end.put_line(‘Sum of three numbers= ‘||s). hire date. x:=x+1. f number:=1.put_line(‘Factorial of ‘||n||’= ‘||f). / • WAP to get the hiredate of an employee from the emp table and print it.

.... dbms_output........... / • Package body creation create or replace package body my_pack is procedure addpro(no1 in number.Package body definition:create or replace package body <<pack body name>> as/is procedure <<pro name1>> (arg1 dtype... function divfun(no1 in number.....no2 in number) return number... . . 1.arg2 dtype) is procedure definition ...no2 in number). procedure <<pro name2>> (arg1 dtype....Package definition:syntax:create or replace package <<package name>> as/is procdure and function inclusion end <<packagename>>.While calling the procedures and function they should be written along with the package name.. end <<pro_name2>>...put_line(‘The employee is hired on ‘||to_char(hire... end my_pack.’day ddth month yyyy’) ). begin s:=no1+no2...........Package body definition 1.. end <<pro_name1>>.... / PACKAGES:This is also a stored program unit which is a combination of more than one procedures or functions...There are two parts in a packege... .no2 in number) is s number..no2 in number).Package definition 2.no2 in number) return number ..begin e:=&empno.. end..arg2 dtype) is procedure definition .. hire:=funhire(e).. procedure subpro(no1 in number...... / 2.... create or replace package my_pack is procedure addpro(no1 in number. function profun(no1 in number...

begin d:=no1-no2.20) etc.no2 in number) return number is q number.put_line(‘Difference of the two numbers=’||d).for deleting a record from the student table.put_line(‘Quotient of the two numbers=’||q).divfun(n1.2). begin q:=no1/no2. procedure subpro(no1 in number. dbms_output. function profun (no1 in number. / exec my_pack.30) exec my_pack.subpro(34. q number(5. result and division 3. after that write a program to call all of those. p number(5). ./ • dbms_output.profun(n1.no2 in number) is d number. end profun. end addpro.no2 in number) return number is p number. function divfun (no1 in number.addpro(20. average. end divfun. To find product and quotient declare n1 number(4):=&no1. return q. dbms_output. n2 number(4):=&no2.For adding the student data to a table 2.sname varchar2) . q:=my_pack. begin p:=no1*no2.For calculating the total. end.put_line(‘Product of the two numbers=’||p). dbms_output.put_line(‘Sum of the two numbers=’||s). begin p:=my_pack. end subpro. return p. • Create a package with three procedures 1.n2).n2). end my_pack. Create or replace package pack_me is Procedure adddata (no number. end if.s2 number. a:=t/3. else re:=’fail’. end adddata.s1 number.deldata(102) Database triggers:- . end deldata.s2 number.Procedure caldata(no number. end caldata.sname). procedure caldata (no number. elsif re=’pass’ and a>=50 then di:=’second’. a stud. re stud.res%type.tot=t.sub2=s2. elsif re=’pass’ and a>=35 then di:=’third’.sub3=s3. procedure deldata(no number) is begin delete from stud where rno=no. End pack_me.res=re. di stud. else di:=’Nill’.caldata(101.s3 number).div=di where rno=no. begin t:=s1+s2+s3.adddata(102.s3 number) is t stud.sname varchar2) is begin insert into stud (rno. / create or replace package body pack_me is procedure adddata(no number.s1 number. if re=’pass’ and a>=60 then di:=’first’. Procedure deldata(no number) . update stud set sub1=s1.div%type.55. end pack_me.avr%type.’bbbb’) exec pack_me. / exec pack_me.tot%type.avr=a.65) exec pack_me. if s1>=35 and s2>=35 and s3>=35 then re:=’pass’. end if.

drop table stock. . if (deleting) then m:=’u are deleting’. / Create a trigger to update the stock table when purchased and sold.iname varchar2(10). drop table purchase.The triger always fires for each row in the table. end.Before insert or update or delete Syntax:create or replace trigger <<trigg name>> after/before insert or update or delete on <<table name>> for each row declare <<declaration section>> begin <<execution part>> end. end if. end if.’ddth month yyyy hh:mi am’).time). insert into mess values(m. if (updating) then m:=’u are updating’.time varchar2(30)). create or replace trigger mytri before insert or update or delete on stud for each row declare m varchar2(20).Triggers are of two types according to the time of firing. create table mess(mess varchar2(20).Those are 1.After insert or update or delete 2. time varchar2(30). time:=to_char(sysdate. drop table mess. create table stock(itemno number(3) constraints st_pk primary key. begin if (inserting) then m:=’you are inserting’.Triggers are the stored program units which fires when a dml statement encounters the table based on which it is created. end if.qstock number(4)).

end. create table bank_trans(acno number(3) references bank_main(acno). begin select qstock into q from stock where itemno=:new.’cooler’. insert into stock values(103.bal number(10. create table sales(itemno number(3) references stock(itemno).20000).itemno. else update stock set qstock=q-:new. / create or replace trigger sale_trig after insert on sales for each row declare q number(4). begin select qstock into q from stock where itemno=:new.itemno. payeename varchar2(10).100).create table purchase(itemno number(3) references stock(itemno). ahname varchar2(10). if q<:new.trtype varchar2(10).2)).qsold then raise_application_error(‘-20001’.qpur where itemno=:new.qpur number(4)). tramount number(10.100).’suitcase’. create or replace trigger pur_tri after insert on purchase for each row declare q number(4).iname varchar2(10). insert into stock values(101.100). insert into bank_main values(102. / • • • • • • • • • • • create a table for bank and write a trigger for transaction.’tv’. drop table sales. update stock set qstock=q+:new. end if. create table bank_main(acno number(3) constraints b_pk primary key.2)).100). end.qsold number(4)).’rajesh’. insert into bank_main values(101.’Insufficient stock’).iname varchar2(10). insert into stock values(104.qsold where itemno=:new.10000).’Suresh’. insert into stock values(102.itemno.itemno. .’fridge’.

trtype=’withdraw’ and b<:new. if :new. elsif :new.’Insufficient balance.’Today is Sunday’).’This is not working hour’). • elsif to_char(sysdate.4500). • elsif to_char(sysdate. / --Create a trigger to calculate the total and average marks for 3 subjects after inserting the marks to the student table. end.’d’)=1 then • raise_application_error(-20003.overdraft’).2).tramount where acno=:new. . elsif :new.trtype=’deposit’ then update bank_main set bal=b+:new.5000).’Simran’.’dd’)=23 and to_char(sysdate. insert into bank_main values(105.’mon’)=’feb’ then raise_application_error(-20005. begin select bal into b from bank_main where acno=:new. insert into bank_main values(104. end.trtype=’withdraw’ then update bank_main set bal=b-:new.’hh24’) not between 9 and 13 then • raise_application_error(-20004.7500). create or replace trigger trans_tri after insert on bank_trans for each row declare b number(10.acno.’Satish’.acno.acno.• • • • • • • • • • • • • • • • • • • • insert into bank_main values(103.’Today this is Holiday for Bakrid’). end if. / create or replace trigger date_tri before insert or update or delete on bank_trans for each row • begin • if to_char(sysdate.’Priya’. end if.tramount then raise_application_error(-20002.tramount where acno=:new.

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.