Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
86 views

Lab Manual

The document describes various data definition language (DDL), data manipulation language (DML), and transaction control language (TCL) commands in SQL. Some key commands covered are CREATE TABLE to define a table structure, INSERT to add rows, SELECT to retrieve rows, UPDATE and DELETE to modify rows, COMMIT and ROLLBACK to manage transactions, and MAX, MIN, COUNT, SUM functions. Examples are provided of executing these commands on sample tables to demonstrate their usage and output.

Uploaded by

Lokesh Palanivel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views

Lab Manual

The document describes various data definition language (DDL), data manipulation language (DML), and transaction control language (TCL) commands in SQL. Some key commands covered are CREATE TABLE to define a table structure, INSERT to add rows, SELECT to retrieve rows, UPDATE and DELETE to modify rows, COMMIT and ROLLBACK to manage transactions, and MAX, MIN, COUNT, SUM functions. Examples are provided of executing these commands on sample tables to demonstrate their usage and output.

Uploaded by

Lokesh Palanivel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 82

EXP.

N0:1a DATA DEFINITION LANGUAGE [DDL]


DATE:

AIM:
To execute the DATA DEFINITION LANGUAGE (DDL) commands.

CREATING A TABLE

SYNTAX:
create table <table name> (column 1 datatype 1,
……., column n datatype n);

EXPLANATION:

Create command is used to create a table in the database.

EXAMPLE:

SQL> create table student (VT number, name varchar (10));

OUTPUT:
Table created.

DESC COMMAND

SYNTAX:
desc <table name>;

EXPLANATION:

This command is used to view the structure of the table.

EXAMPLE:

SQL> desc student;


OUTPUT:
NAME NULL? TYPE

VT NUMBER
NAME VARCHAR (10)

ALTERING A TABLE

EXPLANATION:

The structure of the table can be changed using this command like
add new column, change the width of a datatype, change the datatype
of a column.

1. MODIFY

SYNTAX:
alter table <table name> modify (column datatype, …);

EXAMPLE:

SQL> alter table student modify (name varchar (20));

OUTPUT:
Table altered.

ADD / DROP

SYNTAX:
alter table <table name> add/drop (column datatype, …);

EXAMPLE:

SQL> alter table student add (dept varchar


(20)); SQL> alter table student drop (addr);

OUTPUT:
Table altered.
TRUNCATING A TABLE
SYNTAX:
truncate table <table name>;

EXPLANATION:

This command is used to delete all records stored in a table, but


the structure of the table is retained.

EXAMPLE:

SQL> truncate table student;

OUTPUT:
Table truncated.

DROPPING A TABLE

SYNTAX:
drop table <table name>;

EXPLANATION:

This command is used to remove a table from the database.

EXAMPLE:

SQL> drop table student;

OUTPUT:
Table dropped.

RESULT:
Thus, the data definition language commands were executed and their
outputs were verified
EXP.N0:1b DATA MANIPULATION LANGUAGE [DML]
DATE:

AIM:
To execute the DATA MANIPULATION LANGUAGE (DML) commands.

INSERT COMMANDS

1. INSERT A ROW WITH VALUES FOR COLUMNS IN A TABLE.

SYNTAX:
insert into <table name> values (value1, value2,……, value n);

EXPLANATION:

This insert command is used to add rows to a table in the database.

EXAMPLE:
SQL> insert into student values (4169, „rameeze‟);

OUTPUT:
1 row created.

2. INSERT A LARGE NUMBER OF ROWS.

SYNTAX:
insert into <table name> values (&value1, &value2,……, &value n);

EXPLANATION:

This insert command is used to add multiple rows to a table in


the database.

EXAMPLE:
SQL> insert into student values (&vt, „&name‟);
OUTPUT:
Enter value for vt: 4169
Enter value for name: rameeze
Old 1: insert into student values (&vt, „&name‟)
New 1: insert into student values (4169, „rameeze‟)
1 row created.

SELECT COMMANDS

1. SELECT ALL ROWS FROM A TABLE.

SYNTAX:
select * from <table name>;

EXPLANATION:

This select command is used to retrieve all the values stored in the table.

EXAMPLE:
SQL> select * from student;

OUTPUT:

VT NAME

4169 RAMEEZE

2. SELECT DISTINCT ROWS FROM A TABLE.

SYNTAX:
select <field name> from <table name>;

EXPLANATION:

This select command is used to retrieve the particular field values stored
in the table.

EXAMPLE:
SQL> select name from student;

OUTPUT:

RAMEEZE
3. SELECT USING WHERE COMMAND.

SYNTAX:
select <field name> from <table name> where <search condition>;

EXPLANATION:

This select command is used to retrieve the particular field values,


stored in the table, which satisfy a required condition.

EXAMPLE:
SQL> select name from student where vt=4169;

OUTPUT:

NAME

RAMEEZE

UPDATE COMMAND

SYNTAX:
update <table name> set column1=expression, column 2=expression, ……,
column n=expression where <search condition>;

EXPLANATION:

This command is used to update (changing values in) one or two columns
of a row in a table. Specific rows can be updated based on some
condition.

EXAMPLE:
SQL> update student set name=‟md rameeze‟ where vt =4169;

OUTPUT:

1 row updated.
SQL> select * from student;

VT NAME

4169 MD RAMEEZE
DELETE COMMAND

SYNTAX:
delete from <table name> where <search condition>;

EXPLANATION:

This command is used to delete a row from a table.

EXAMPLE:
SQL> delete from student where vt =4169;

OUTPUT:
1 row deleted.

SQL> select * from student;

no rows selected.

RESULT:
Thus, the data manipulation language commands were executed and their
outputs were verified.
EXP.N0: 1c TRANSACTION CONTROL COMMANDS TCL
DATE:

AIM
To execute the transaction control commands TCL
TRANSACTION CONTROL LANGUAGE
• Transaction control language is statements to manage the changes made by DML statements.
• It allows statements to be grouped together into logical transactions. There are lots of TCL
commands which are used in SQL in which some are namely defined as follows:
✓ COMMIT

✓ SAVEPOINT

✓ ROLLBACK

SET OPERATORS
SQL set operators allows combine results from two or more SELECT statements.
✓ UNION

✓ UNIONALL

✓ INTERSECT

✓ MINUS
ARITHMETIC OPERATORS
Arithmetic operators can perform arithmetical operations on numeric operands involved.
✓ MAX

✓ MIN

✓ COUNT
✓ AVG

✓ SUM
SQL COMMANDS

1. COMMAND NAME: COMMIT


Command is used to save the work done.

2. COMMAND NAME: SAVE POINT


Command is used to identify a point in a transaction in which it can be restored using Roll
back command.

3. COMMAND NAME: ROLLBACK


Command is used to restore database to original since last commit.

4. COMMAND NAME: MAX


Command is used to find the maximum among the entities in a particular attribute.

5. COMMAND NAME: MIN


Command is used to find the minimum among the entities in a particular attribute.

6. COMMAND NAME: COUNT


Command is used to count the entire entities in a particular attribute.

7. COMMAND NAME: SUM


Command is used to add all the entities within the attribute.

8. COMMAND NAME: UNION


Command is used to compile all distinct rows and display all entities in both rows.
9. COMMAND NAME: UNIONALL
Command is used to return all entities in both rows.

10. COMMAND NAME: INTERSECT


Command is used to display only similar entities in both rows.

11. COMMAND NAME: MINUS


Command is used to display only the rows that match in both queries.

EXECUTION
TABLE CREATION:
SQL> create table emp1(emp_name varchar2(10),emp_no number primary key,dept_no
number,dept_name varchar2(10));
Table created.
SQL> create table em1(emp_name varchar2(10),emp_no number primary key,dept_no
number,dept_name varchar2(10));
Table created.
INSERTING VALUES:
SQL> insert into emp1 values('vijay',345,54,'cse');
1 row created.
SQL> insert into emp1 values('ajay',35,6,'cse');
1 row created.
SQL> insert into em1 values('ajay',35,6,'cse');
1 row created.
SQL> insert into em1 values('vinoth',45,504,'cse');
1 row created.
DISPLAY THE TABLE:
SQL> select * from emp1;
EMP_NAME EMP_NO DEPT_NO DEPT_NAME
---------- ---------- ---------- ----------
vijay 345 54 cse
ajay 35 6 cse
SQL> select * from em1;
EMP_NAME EMP_NO DEPT_NO DEPT_NAME
---------- ---------- ---------- ----------
ajay 35 6 cse
vinoth 45 504 cse
COMMIT & ROLLBACK COMMAND:
SQL> commit;
Commit completed.
SQL> delete from em1 where emp_no=45;
1 row deleted.
SQL> select * from em1;
EMP_NAME EMP_NO DEPT_NO DEPT_NAME

---------- ---------- ---------- ----------


ajay 35 6 cse
SQL> rollback;
Rollback complete.
SQL> select * from em1;
EMP_NAME EMP_NO DEPT_NO DEPT_NAME
ajay 35 6 cse
vinoth 45 504 cse
ARITHMETIC OPERATORS
SQL> select sum(dept_no) from em1;
SUM(DEPT_NO)
------------
600
SQL> select max(dept_no) from em1;
MAX(DEPT_NO)
------------
504
SQL> select avg(dept_no) from em1;
AVG(DEPT_NO)
------------
300
SQL> select min(dept_no) from em1;
MIN(DEPT_NO)
------------
6
SQL> select count(dept_no) from em1;
COUNT(DEPT_NO)
--------------
2

SET OPERATORS
SQL> insert into em1 values('arjun',87,978,'mech');
1 row created.
SQL> insert into em1 values('akshai',83,98,'it');
1 row created.
SQL> insert into emp1 values('akash',38,56,'eee');
1 row created.
SQL> insert into emp1 values('arjun',87,978,'mech');
1 row created.
SQL> select * from em1;
EMP_NAME EMP_NO DEPT_NO DEPT_NAME
ajay 35 6 cse
vijay 345 54 cse
arjun 87 978 mech
akshai 83 98 it
SQL> select * from emp1;
EMP_NAME EMP_NO DEPT_NO DEPT_NAME
akash 38 56 eee
arjun 87 978 mech
SQL> select emp_no from em1 union select emp_no from emp1;
EMP_NO
35
38
83
87
345
SQL> select emp_no from em1 union all select emp_no from emp1;
EMP_NO
35
83
87
345
38
87
6 rows selected.
SQL> select emp_no from em1 intersect select emp_no from emp1;
EMP_NO
----------
87
SQL> select emp_no from em1 minus select emp_no from emp1;
EMP_NO
----------
35
83
345

RESULT:
Thus the TCL commands were executed and their outputs were verified.
EXP.N0:2a QUERIES IN SQL

AIM:
To write and execute simple,nested and joins queries in SQL.

TYPES OF COMMANDS:

JOIN QUERIES

Join is a query in which data is returned from two or more tables.

✓ INNER JOIN
✓ LEFT OUTER JOIN
✓ RIGHT OUTER JOIN
✓ FULL OUTER JOIN
NESTED QUERIES

• A subquery is a query within a query. In Oracle, you can create subqueries within your SQL
statements.
• These subqueries can reside in the WHERE clause, the FROM clause, or the SELECT clause.

SQL COMMANDS

1. COMMAND NAME: INNER JOIN

Command returns the matching rows from the tables that are being joined.

2. COMMAND NAME: LEFT OUTER JOIN

Command returns matching rows from the tables being joined and also non-matching row
from the left table in the result and places null values in the attributes that come from the right
side table.
3. COMMAND NAME: RIGHT OUTER JOIN

Command returns matching rows from the tables being joined and also non-matching row
from the right table in the result and places null values in the attributes that come from the left
side table.

COMMAND NAME: FULL JOIN:


It is the combination of both left outer and right outer join.

5. COMMAND NAME: NESTED QUERY

Command have query within another query.

EXECUTION

TABLE CREATION

SQL> create table emp_det(eno number(3) not null, ename varchar2(25),address varchar2(30),
basic_sal number(12,2),job_status varchar2(15),dno number(3));

Table created.

SQL> create table pro_det(pno number(3) not null,pname varchar2(30), no_of_staff number(3));

Table created.

SQL> create table work_in(pno number(3),eno number(3),pjob char(12));

Table created.

SQL> desc emp_det;


Name Null? Type

ENO NOT NULL NUMBER(3)

ENAME VARCHAR2(25)

ADDRESS VARCHAR2(30)

BASIC_SAL NUMBER(12,2)

JOB_STATUS VARCHAR2(15)

DNO NUMBER(3)

SQL> desc pro_det;

Name Null? Type

PNO NOT NULL NUMBER(3)

PNAME VARCHAR2(30)

NO_OF_STAFF NUMBER(3)

SQL> desc work_in;

Name Null? Type

PNO NUMBER(3)

ENO NUMBER(3)

PJOB CHAR(12)
SQL> insert into emp_det values(&eno,'&ename','&address',&basic_sal,'&job_status',&dno);

Enter value for eno: 1

Enter value for ename: SaravanaKumar

Enter value for address: GandhiNagar

Enter value for basic_sal: 8000

Enter value for job_status: Manager

Enter value for dno: 10

old 1: insert into emp_det values(&eno,'&ename','&address',&basic_sal,'&job_status',&dno)

new 1: insert into emp_det values(1,'SaravanaKumar','GandhiNagar',8000,'Manager',10)

1 row created. SQL> /

Enter value for eno: 2

Enter value for ename: Mahendran

Enter value for address: RainbowColony

Enter value for basic_sal: 5000

Enter value for job_status: Supervisor

Enter value for dno: 10

old 1: insert into emp_det values(&eno,'&ename','&address',&basic_sal,'&job_status',&dno)

new 1: insert into emp_det values(2,'Mahendran','RainbowColony',5000,'Supervisor',10)

1 row created.
SQL> /

Enter value for eno: 3

Enter value for ename:Rajkumar

Enter value for address: EastCoastRoad

Enter value for basic_sal: 10000

Enter value for job_status: Professor

Enter value for dno: 2

old 1: insert into emp_det values(&eno,'&ename','&address',&basic_sal,'&job_status',&dno)

new 1: insert into emp_det values(3,'RajKumar','EastCoastRoad',10000,'Professor',2)

1 row created. SQL> /

Enter value for eno: 4

Enter value for ename: Shirley

Enter value for address: KKnagar

Enter value for basic_sal: 8000

Enter value for job_status: AsstManager

Enter value for dno: 3

old 1: insert into emp_det values(&eno,'&ename','&address',&basic_sal,

'&job_status',&dno)
new 1: insert into emp_det values(4,'Shirley','KKnagar',8000,

'AsstManager',3)

1 row created.

SQL> alter table emp_det modify(ename varchar2(15), address varchar2(15)); Table altered.

SQL> select * from emp_det;

ENO ENAME ADDRESS BASIC_SAL JOB_STATUS DNO

1 SaravanaKumar GandhiNagar 8000 Manager 10

2 Mahendran RainbowColony 5000 Supervisor 10

3 RajKumar EastCoastRoad 10000 Professor 2

4 Shirley KKnagar 8000 AsstManager 3

SQL> insert into pro_det values(&pno,'pname',&no_of_staff);

Enter value for pno: 1

Enter value for no_of_staff: 2

old 1: insert into pro_det values(&pno,'pname',&no_of_staff)

new 1: insert into pro_det values(1,'pname',2)

1 row created. SQL> /

Enter value for pno: 2

Enter value for no_of_staff: 3


old 1: insert into pro_det values(&pno,'pname',&no_of_staff)

new 1: insert into pro_det values(2,'pname',3)

1 row created.

SQL> /

Enter value for pno: 3

Enter value for no_of_staff: 1

old 1: insert into pro_det values(&pno,'pname',&no_of_staff)

new 1: insert into pro_det values(3,'pname',1)

1 row created.

SQL> select * from pro_det;

PNO PNAME NO_OF_STAFF

1 pname 2

2 pname 3

3 pname 1

SQL>update pro_det set pname='DBMS' where pno=1;

1 row updated.

SQL> update pro_det set pname='COMPILER' where pno=2;

1 row updated.
SQL>update pro_det set pname='C' where pno=3;

1 row updated.

SQL> select * from Pro_det;

PNO PNAME NO_OF_STAFF

1 DBMS 2

2 COMPILER 3

3 C 1

SQL> insert into work_in values(&pno,&eno,'&pjob'); Enter value for pno: 1

Enter value for eno: 1

Enter value for pjob: Programmer

old 1: insert into work_in values(&pno,&eno,'&pjob')

new 1: insert into work_in values(1,1,'Programmer')

1 row created. SQL> /

Enter value for pno: 2

Enter value for eno: 1

Enter value for pjob: Analyst

old 1: insert into work_in values(&pno,&eno,'&pjob')

new 1: insert into work_in values(2,1,'Analyst')

1 row created. SQL> /


Enter value for pno: 1

Enter value for eno: 2

Enter value for pjob: Analyst

old 1: insert into work_in values(&pno,&eno,'&pjob')

new 1: insert into work_in values(1,2,'Analyst')

1 row created.

SQL> /

Enter value for pno: 2

Enter value for eno: 2

Enter value for pjob: Programmer

old 1: insert into work_in values(&pno,&eno,'&pjob')

new 1: insert into work_in values(2,2,'Programmer')

1 row created.

SQL> select * from work_in;

PNO ENO PJOB

1 1 Programmer

2 1 Analyst

1 2 Analyst

2 2 Programmer
EXP.N0:2.b NESTED QUERIES
DATE:

i)SQL> select ename from emp_det where dno not in(select dno from emp_det where ename
='SaravanaKumar');

ENAME

RajKumar

Shirley

ii)SQL> select ename, dno from emp_det where dno = (select dno from emp_det where ename
='RajKumar');

ENAME DNO

RajKumar 2

(iii)SQL> select ename from emp_det where eno in(select eno from work_in where pno = (select
pno from pro_det where pname = 'DBMS')) order by ename;

ENAME

-Mahendran SaravanaKumar

(iv)SQL> select ename, basic_sal from emp_det where dno = 2 and basic_sal>(select
max(basic_sal) from emp_det where dno = 10) order by ename;

ENAME BASIC_SAL

RajKumar 10000

(v)SQL> select pno,pname from pro_det where exists(select pno from work_in where
work_in.pno =pro_det.pno);

PNO PNAME

1 DBMS

2 COMPILER
(vi)SQL>select ename, job_status,basic_sal from emp_det where (dno,basic_sal) in (select
dno,basic_sal from emp_det where ename ='RajKumar');

ENAME JOB_STATUS BASIC_SAL

RajKumar Professor 10000

(vii)SQL>select * from emp_det where basic_sal=(select max(basic_sal) from emp_det);

ENO ENAME ADDRESS BASIC_SAL JOB_STATUS DNO

3 RajKumar EastCoastRoad 10000 Professor 2

(viii)SQL>select max(basic_sal) from emp_det where basic_sal< (select max(basic_sal) from


emp_det); MAX(BASIC_SAL)

8000

(ix)SQL> select * from emp_det where basic_sal < (select avg(basic_sal) from emp_det);

ENO ENAME ADDRESS BASIC_SAL JOB_STATUS DNO

2 Mahendran RainbowColony 5000 Supervisor 1

2c) JOINS

SQL> create table emp(name varchar2(20),salary number(10));

Table created.

SQL> insert into emp values('&name',&salary);

Enter value for name: ashu

Enter value for salary: 10000


old 1: insert into emp values('&name',&salary)

new 1: insert into emp values('ashu',10000)

1 row created.

SQL> /

Enter value for name: asma

Enter value for salary: 1200

old 1: insert into emp values('&name',&salary)

new 1: insert into emp values('asma',1200)

1 row created.

SQL> /

Enter value for name: asif

Enter value for salary: 2000

old 1: insert into emp values('&name',&salary)

new 1: insert into emp values('asif',2000)

1 row created. SQL> /

Enter value for name: arif

Enter value for salary: 1000

old 1: insert into emp values('&name',&salary)

new 1: insert into emp values('arif',1000)

1 row created. SQL> /


Enter value for name: niyas

Enter value for salary: 3000

old 1: insert into emp values('&name',&salary)

new 1: insert into emp values('niyas',3000)

1 row created.

SQL> select * from emp;

NAME SALARY

Ashu 10000

Asma 1200

Asif 2000

Arif 1000

Niyas 3000

SQL> create table emp1(name varchar2(20),empid number(10));

Table created.

SQL> insert into emp1 values('&name',&empid);

Enter value for name: fathi

Enter value for empid: 12

old 1: insert into emp1 values('&name',&empid)

new 1: insert into emp1 values('fathi',12)

1 row created. SQL> /


Enter value for name: sumi

Enter value for empid: 32

old 1: insert into emp1 values('&name',&empid)

new 1: insert into emp1 values('sumi',32)

1 row created.

SQL> /

Enter value for name: priya

Enter value for empid: 11

old 1: insert into emp1 values('&name',&empid)

new 1: insert into emp1 values('priya',11)

1 row created.

SQL> /

Enter value for name: wahab

Enter value for empid: 10

old 1: insert into emp1 values('&name',&empid)

new 1: insert into emp1 values('wahab',10)

1 row created. SQL> /

Enter value for name: sweety

Enter value for empid: 09


old 1: insert into emp1 values('&name',&empid)

new 1: insert into emp1 values('sweety',09)

1 row created. SQL>/

Enter value for name: asma

Enter value for empid: 1200

old 1: insert into emp1 values('&name',&empid)

new 1: insert into emp1 values('asma',1200)

1 row created.

SQL> select * from emp1;

NAME EMPID

fathi 12

sumi 32

priya 11

wahab 10

sweety 9

asma 1200

6 rows selected.

NATURAL JOIN

SQL>select emp.name,salary from emp,emp1 where emp.name=emp1.name;


NAME SALARY

asma 1200

LEFT OUTER JOIN

SQL>select emp.name,salary from emp left outer join emp1 on emp.name=emp1.name;

NAME SALARY

Asma 1200

Asif 2000
Arif 1000
Niyas 3000
Ashu 10000

RIGHT OUTER JOIN

SQL>select emp1.name,empid from emp right outer join emp1 on emp.name=emp1.name;

NAME EMPID

asma 1200
sweety 9
sumi 32
wahab 10
fathi 12
priya 11

6 rows selected.
FULL JOIN
SQL>select emp1.name,emp.name,emp1.empid,salary from emp full join emp1 on
emp.name=emp1.name;
NAME NAME EMPID SALARY

asma asma 1200 1200

asif 2000

arif 1000

niyas 3000

ashu 10000

sweety 9
sumi 32
wahab 10
fathi 12
priya 11

RESULT:
Thus the simple, nested ,join queries were executed and their outputs were
verified.
EX.NO:3 a SQL COMMANDS FOR VIEWS
DATE:

VIEWS

AIM:
To study the Simple View and Complex View and to execute them.

SQL COMMANDS

1. COMMAND NAME: CREATE VIEW

Command is used to define a view.

2. COMMAND NAME: INSERT IN VIEW

Command is used to insert a new row into the view.

3. COMMAND NAME: DELETE IN VIEW

Command is used to delete a row from the view.

4. COMMAND NAME: UPDATE OF VIEW

Command is used to change a value in a tuple without changing all values in the tuple.

5. COMMAND NAME: DROP OF VIEW

Command is used to drop the view table

TABLE CREATION:

SQL> create table emp(emp_name varchar2(10),emp_no number(8),dept_name


varchar2(10),dept_no number(5),doj date);

Table created.
TABLE DESCRIPTION:

SQL> desc emp;

Name Null? Type

EMP_NAME VARCHAR2(10)

EMP_NO NUMBER(8)

DEPT_NAME VARCHAR2(10)

DEPT_NO NUMBER(5)

DOJ DATE

CREATION OF VIEW:

SQL> create view empview as select emp_name,emp_no,dept_name,dept_no,doj from emp;

View created.

DESCRIPTION OF VIEW:

SQL> desc empview;

Name Null? Type

EMP_NAME VARCHAR2(10)

EMP_NO NUMBER(8)

DEPT_NAME VARCHAR2(10)

DEPT_NO NUMBER(5)

DOJ DATE
INSERT TABLE VALUES:

SQL> insert into emp values('akash',124,'ece',89,'15-jun-95');

1 row created.

SQL> insert into emp values('ashith',186,'cse',86,'10-sep-75');

1 row created.

SQL> insert into empview values('akshai',106,'it',46,'19-aug-87');

1 row created.

DISPLAY TABLE VIEW:

SQL> select * from empview;

EMP_NAME EMP_NO DEPT_NAME DEPT_NO DOJ

akash 124 ece 89 15-JUN-95

ashith 186 cse 86 10-SEP-75

akshai 106 it 46 19-AUG-87

MODIFICATION:

SQL> update empview set emp_name='ram' where emp_name='akshai';

1 row updated.

SQL> select * from emp;


EMP_NAME EMP_NO DEPT_NAME DEPT_NO DOJ

akash 124 ece 89 15-JUN-95

ashith 186 cse 86 10-SEP-75

ram 106 it 46 19-AUG-87

SQL> drop view empview;

View dropped.

RESULT
Thus, the Simple view and Complex view were executed and the outputs were verified.
EX.NO:3b SQL COMMANDS FOR SYNONYMS
DATE:
AIM:

To create the Synonyms and verify the various operations on Synonyms

ALGORITHM:

STEP 1: Start the DMBS.

STEP 2: Connect to the existing database(DB)

STEP 3: Create the table with its essential attributes.

STEP 4: Insert record values into the table.

STEP 5: Create the synonyms from the above created table or any data object.

STEP 6: Display the data presented on the synonyms.

STEP 7: Insert the records into the synonyms,

STEP 8: Check the database object table and view the inserted values presented

STEP 9: Stop the DBMS.


Syntax:

SQL>CREATE SYNONYM synonymName FOR object;

OR

SQL>CREATE SYNONYM tt for test1;

Dependent Oject - tt (SYNONYM NAME )


Referenced Object - test1 (TABLE NAME)
USAGE:
Using emp you can perform DML operation as you have create sysnonm for table object
If employees table is dropped then status of emp will be invalid.

Local Dependencies are automatically managed by oracle server.

COMMANDS:
CREATE THE TABLE
SQL> CREATE TABLE student_table(Reg_No number(5),NAME varchar2(5),MARK number(3));
Table

INSERT THE VALUES INTO THE TABLE


SQL> insert into student_table
values(10001,'ram',85); 1 row created.

SQL> insert into student_table


values(10002,'sam',75); 1 row created.

SQL> insert into student_table


values(10003,'samu',95); 1 row created.

SQL> select * from STUDENT_TABLE;


REG_NO NAME MARK
10001 ram 85

10002 sam 75

10003 samu 9

CREATE THE SYNONYM FROM TABLE


SQL> CREATE SYNONYM STUDENT_SYNONYM FOR STUDENT_TABLE;
Synonym created.

DISPLAY THE VALUES OF TABLE BY USING THE SYSNONYM


SQL> select * from STUDENT_SYNONYM;

REG_NO NAME MARK


10001 ram 85
10002 sam 75
10003 samu 95

INSERT THE VALUES TO THE SYNONYM


SQL> insert into student_SYNONYM values(10006,'RAJA',80);
1 row created.

DISPLAY THE VALUES IN BOTH TABLE AND SYNONYM


SQL> select * from STUDENT_TABLE;
REG_NO NAME MARK
10001 ram 85

10002 sam 75
10003 samu 95
10006 RAJA 80
SQL> select * from STUDENT_SYNONYM;

REG_NO NAME MARK


10001 ram 85
10002 sam 75
10003 samu 95
10006 RAJA 80

YOU CAN UPDATE THE TABLE BY USING SYNONYM


SQL> UPDATE STUDENT_SYNONYM SET MARK=100 WHERE REG_NO=10006;
1 row updated.

SQL> select * from STUDENT_SYNONYM;


REG_NO NAME MARK
10001 ram 85
10002 sam 75
10003 samu 95
10006 RAJA 100

SQL> select * from STUDENT_TABLE;

REG_NO NAME MARK


10001 ram 85
10002 sam 75
10003 samu 95
10006 RAJA 100
TO DROP SYSNONYM
SQL> DROP SYNONYM STUDENT_SYNONYM;
Synonym dropped.

BUT WE CAN USE THE TABLE


SQL> select * from STUDENT_TABLE;

REG_NO NAME MARK


10001 ram 85
10002 sam 75
10003 samu 95

10006 RAJA 100

RESULT:

Thus the SQL commands for creation and various operation on Synonyms has been verified
and executed successfully.
EX.NO:3C SQL COMMANDS FOR SEQUENCES
DATE:
AIM:

To create the Sequence and verify the various operations on Sequence to get
the incremented number.

ALGORITHM:
Step 1: Start the DMBS.
Step 2: Connect to the existing database (DB)
Step 3: Create the sequence with its essential optional parameter.
Step 4: Display the data presented on the sequence by using pseudo column.
Step 5: Alter the sequence with different optional parameter.

Step 6: Drop the sequence


Step 7: Stop the DBMS.

Creating a Sequence
You create a sequence using the CREATE SEQUENCE statement, which has the following.

SYNTAX:
SQL>CREATE SEQUENCE sequence_name
[START WITH start_num]
[INCREMENT BY increment_num]

[ { MAXVALUE maximum_num | NOMAXVALUE } ] [


{ MINVALUE minimum_num | NOMINVALUE } ]
[ { CYCLE | NOCYCLE } ]

[ { CACHE cache_num | NOCACHE } ] [


{ ORDER | NOORDER } ];
Example: 1

Command:
SQL> CREATE SEQUENCE seq1

INCREMENT BY 1
START with 1
MAXVALUE 5
MINVALUE 0;

Sequence created.
TO DISPLAY THE VALUES OF SEQUENCES
After creating sequence use nextval as nextval is used to generate sequence
values SQL> select seq1.nextval from dual;

NEXTVAL
1
SQL> select seq1.nextval from dual;
NEXTVAL

2
SQL> select seq1.nextval from dual;
NEXTVAL

3
SQL> select seq1.currval from dual;
CURRVAL

3
TO ALTER THE SEQUENCES
alter SEQUENCE
seq1 maxvalue 25
INCREMENT BY
a cycle
cache
2
drop SEQUENCE seq1;

EXAMPLE: 2

CREATE SEQUENCE seq2


INCREMENT BY
1 start with 1
maxvalue 5
minvalue 0
cycle
CACHE 4;

EXAMPLE: 3
CREATE SEQUENCE seq3
INCREMENT BY -
1 start with 2
maxvalue 5
minvalue 0;
EXAMPLE: 4

CREATE SEQUENCE seq3


INCREMENT BY -
1 start with 2
maxvalue 5
minvalue 0
cycle
cache 4;

EXAMPLE: 5
CREATE SEQUENCE seq1
INCREMENT BY
1 start with 1
maxvalue 10
minvalue 0;

EXAMPLE: 6
create table test1(a number primary key);

TO INSERT THE VALUES FROM SEQUENCES TO TABLE:


insert into test1 values(seq1.nextval)

RESULT:

Thus the SQL commands for creation and various operations on Sequence has been
verified and executed successfully.
EX.NO:4 CURSORS
DATE:
AIM:
To write and execute Cursors queries in SQL

SYNTAX:

CURSOR cursor_name IS select_statement;

EXECUTION

TABLE CREATION & VALUE INSERTION:

SQL> create table std(rlno number(10),name varchar2(10),dept varchar2(10),tot nmber(10));

Table created.

SQL> insert into std values(111,'jone','cse',440);

1 row created.

SQL> insert into std values(112,'james','ece',460);

1 row created.

SQL> insert into std values(113,'john','eee',450);

1 row created.

DISPLAY THE TABLE:

SQL> select * from std;

RLNO NAME DEPT TOT

111 jone cse 440

112 james ece 460

113 john eee 450


CREATING A CURSOR:

SQL> set serveroutput on;


SQL> declare

2 cursor c is select * from std order by tot desc;


3 a std% rowtype;
4 n number:=0;
5 begin
6 open c;
7 loop
8 fetch c into a;
9 exit when c% notfound or c% rowcount>5;
10 insert into std1 values(a.rlno,a.name,a.dept,a.tot);
11 end loop;
12 close c;
13 commit;
14 end;
15 /
PL/SQL procedure successfully completed.

OUTPUT:

SQL> select * from std1;

RLNO NAME DEPT TOT

112 james ece 460

113 john eee 450

111 jone cse 440


IMPLICIT CURSOR
DECLARE
Eid number(3);
BEGIN
UPDATE emp set eid=&eid where salary=&salary; eid:=sql%rowcount;
IF SQL%found then
dbms_output.put_line('success');
ELSE
dbms_output.put_line ( ' not' ) ;
END IF;
dbms_output.put_line( 'rowcount'||eid);
END;
/
OUTPUT:
success
PL/SQL Procedure successfully completed.

EXPLICIT CURSOR

DECLARE
CURSOR er IS select eid,name from emp order by name ;
id emp.eid%type;
ename emp.name%type;
BEGIN
OPEN er;
Loop
FETCH er into id,ename;
Exit when er%notfound;
dbms_output.put_line (id || ename);
end loop;
close er;
END;

OUTPUT:

1||parimal
2||preet
PL/SQL Procedure successfully completed.

RESULT:
Thus, the Cursors were executed and the outputs were verified.
EXP.N0:5 HIGH LEVEL PROGRAMMING LANGUAGE EXTENSIONS
FUNCTIONS AND PROCEDURES

AIM:

To implement FUNCTIONS using STRUCTURED QUERY


LANGUAGE.

ALGORITHM:
1. Create the function using function name.
2. Declare the variables to be used.
3. Begin the function.
4. Specify the operations.
5. Return the value to the variable declared.
6. End.
7. Procedure does not return value, but helps to call a function.

SYNTAX:
Create or replace function < function_name > [ argument ]
return datatype is
(local declaration)
Begin
(executable statements)
[Exception]
(exception handlers)
end;
EXECUTION
TABLE CREATION & VALUE INSERTION:
SQL> create table phonebook(pno number(6) primary key,username varchar2(30),doorno
varchar2(10),street varchar2(30),place varchar2(30),pincode char(6));
Table created.
SQL> insert into phonebook values(20312,'vijay','120/5D','bharathi street','NGO
colony','629002');
1 row created.
SQL> insert into phonebook values(29467,'vasanth','39D4','RK bhavan','sarakkal vilai','629002');
1 row created.
DISPLAY THE TABLE:
SQL> select * from phonebook;
PNO USERNAME DOORNO STREET PLACE
PINCODE
20312 vijay 120/5D bharathi street NGO colony 629002
29467 vasanth 39D4 RK bhavan sarakkal vilai 629002
CREATING A FUNCTION:
SQL> set serveroutput on
SQL> create or replace function findAddress(phone in number)return varchar2 as address
varchar2(100);
2 begin
3 select username||','||doorno||','||street||','||place||','||pincode int address from phonebook where
pno=phone;
4 return address;
5 exception
6 when no_data_found then return 'address not found';
7 end;
8 /
Function created.
SQL> declare
2 address varchar2(100);
3 begin
4 address:=findaddress(20312);
5 dbms_output.put_line(address);
6 end;
7 /
OUTPUT 1:
vijay,120/5D,bharathi street,NGO colony,629002
PL/SQL procedure successfully completed.

SQL> declare
2 address varchar2(100);
3 begin
4 address:=findaddress(23556);
5 dbms_output.put_line(address);
6 end;
7 / OUTPUT 2:
address not found
PL/SQL procedure successfully completed.
PROCEDURES
SYNTAX:
Create or replace procedure <proc_name>[parameter list]is
<local declaration>
Begin
(executable statements)
[exception] (exception handlers)
End;
EXECUTION:
TABLE CREATION & VALUE INSERTION:
SQL> create table stdnt1(rno number(4),name varchar2(20),mk1 number(3),mk2 number(3),mk3
number(3),mk4 number(3),mk5 number(3));
Table created.
SQL> insert into stdnt1 values(101,'preethi',78,88,77,60,89);
1 row created.
SQL> insert into stdnt1 values(102,'sarva',99,77,69,81,99);
1 row created.
SQL> insert into stdnt1 values(103,'suryapriya',100,90,97,89,91);
1 row created.
DISPLAY THE TABLE:
SQL> select * from stdnt1;
RNO NAME MK1 MK2 MK3 MK4 MK5
---------- -------------------- ---------- ---------- ---------- ---------- ----------
101 preethi 78 88 77 60 89
102 sarva 99 77 69 81 99
103 suryapriya 100 90 97 89 91
CREATING PROCEDURES:
SQL> set serveroutput on;
SQL> declare ave number(5,2);
2 tot number(3);
3 cursor c_mark is select * from stdnt1 where mk1>=40 and mk2>=40 and mk3>=40 and
mk4>=40 and mk5>=40;
4 begin
5 dbms_output.put_line('rno name mk1 mk2 mk3 mk4 mk5 total average');
6 dbms_output.put_line('-----------------------------------------------------');
7 for stdnt1 in c_mark
8 loop
9 tot:=stdnt1.mk1+stdnt1.mk2+stdnt1.mk3+stdnt1.mk4+stdnt1.mk5;
10 ave:=tot/5;
11dbms_output.put_line(stdnt1.rno||rpad(stdnt1.name,15)||rpad(stdnt1.mk1,6)||rpad(stdnt1.mk2,6)
||rpad
(stdnt1.mk3,6)||rpad(stdnt1.mk4,6)||rpad(stdnt1.mk5,6)||rpad(tot,8)||rpad(ave,5));
12 end loop;
13 end;
14 /

OUTPUT:
rno name mk1 mk2 mk3 mk4 mk5 total average
----- ------- ------ ------ ------ ------ ------ ----- ------
101 preethi 78 88 77 60 89 392 78.4
102 sarva 99 77 69 81 99 425 85
103 suryapriya 100 90 97 89 91 467 93.4
PL/SQL procedure successfully completed.

RESULT:
Thus, the Functions and Procedures were executed using SQL
and the outputs were verified.
EXP.N0:6 TRIGGERS
DATE:

AIM:

To implement triggers using STRUCTURED QUERY LANGUAGE.


SYNTAX:
create or replace trigger triggername [before/after]
on [tablename] [for each row/statement]
begin
-------------------------
exception
end;

EXECUTION:

TABLE CREATION & INSERTING VALUES:

SQL> create table std(slno number,name varchar2(10),mark1 number(3),mark2 number(3),mark3


number(3));

Table created.

SQL> insert into std values(1,'sharath',100,90,98);

1 row created.

SQL> insert into std values(2,'ram',98,99,79);

1 row created.

SQL> insert into std values(3,'arun',88,98,90);

1 row created.
SQL> select * from std;

SLNO NAME MARK1 MARK2 MARK3

1 sharath 100 90 98

2 ram 98 99 79

3 arun 88 98 90

CREATING A TRIGGER:

SQL> create or replace trigger xxx after update on std

2 for each row

3 begin

4 dbms_output.put_line('mark1 old value:'||:old.mark1);

5 dbms_output.put_line('mark1 new value:'||:new.mark1);

6 dbms_output.put_line('mark2 old value:'||:old.mark2);

7 dbms_output.put_line('mark2 new value:'||:new.mark2);

8 dbms_output.put_line('mark3 old value:'||:old.mark3);

9 dbms_output.put_line('mark3 new value:'||:new.mark3);

10 end;

Trigger created.

SQL> update std set mark1=90,mark2=89,mark3=99 where slno=3;

mark1 old value:88


mark1 new value:90

mark2 old value:98

mark2 new value:89

mark3 old value:90

mark3 new value:99


1 row updated.

OUTPUT:

SQL> select * from std;

SLNO NAME MARK1 MARK2 MARK3

---------- ---------- ---------- ---------- ----------

1 sharath 100 90 98

2 ram 98 99 79

3 arun 90 89 99

RESULT:
Thus, the Triggers were executed using SQL and the outputs were verified.
EXP.N0:7 EXCEPTION HANDLING
DATE:
AIM:

To implement Predefined and user defined exception handling using


STRUCTURED QUERY LANGUAGE.

PREDEFINED EXCEPTION HANDLING

SYNTAX:
Begin
Sequence_of_statements;
Exception
When <exception_name> then
Sequence_of_statements;
When others then
Sequence_of_statements;
End;

EXECUTION:
set serveroutput on;
declare
empid number(5);
emname varchar(50);
begin
empid:=&empid;
select empname into emname from employe where empno=empid;
dbms_output.put_line('The employe name is:'||emname);
exception
when no_data_found then
dbms_output.put_line('data not found');
end;
OUTPUT :
Enter value for empid: 1
old 5: empid:=&empid;
new 5: empid:=1;
The employe name is:radha
PL/SQL procedure successfully completed.
SQL> /
Enter value for empid: 5
old 5: empid:=&empid;
new 5: empid:=5;
data not found
PL/SQL procedure successfully completed.

USER DEFINED EXCEPTION HANDLING

SYNTAX:

<exception_name> exception;

The Syntax for a raise statement is as follows.

raise <exception_name>;

EXECUTION:

declare

co number;

exceeds_value exception;
begin

select count(*) into co from employe;

if co <5 then

insert into employe values (&empno,'&empname','&empst',&empsal);

else

raise exceeds_value;

end if;

exception

when exceeds_value then

dbms_output.put_line('rows will not be inserted');

end;

OUTPUT:

SQL> select * from employe;

EMPNO EMPNAME EMPST SALARY

1 radha leader 20000

2 kavi manager 40000

3 malini analyst 14000

4 arthi admin 21000


SQL> /

Enter value for empno: 5

Enter value for empname: rajeswari

Enter value for empst: software

Enter value for empsal: 25000

old 7: insert into employe values (&empno,'&empname','&empst',&empsal);

new 7: insert into employe values (5,'rajeswari','software',25000);

PL/SQL procedure successfully completed.

SQL> /

Enter value for empno: 6

Enter value for empname: madhavan

Enter value for empst: leader

Enter value for empsal: 24000

old 7: insert into employe values (&empno,'&empname','&empst',&empsal);

new 7: insert into employe values (6,'madhavan','leader',24000);

rows will not be inserted

PL/SQL procedure successfully completed.

SQL> select * from employe;


EMPNO EMPNAME EMPST SALARY

1 radha leader 20000

2 kavi manager 40000

3 malini analyst 14000

4 arthi admin 21000

5 rajeswari software 25000

RESULT:
Thus, the exception handling were executed using SQL and the outputs were
verified.
Ex.No:8 DATABASE DESIGN USING ER MODELING,NORMALIZATION
DATE:

Aim:

To design database using ER modeling and normalization

ER diagram:
Chen Notation

• ORDER (OrderNum (key), OrderDate, SalesPerson)


ORDERITEMS (OrderNum (key)(fk) , ItemNum (key), PartNum, Quantity, Cost)

In the above example, in the ORDERITEMS Relation: OrderNum is the Foreign


Key and OrderNum plus ItemNum is the Composite Key.

Chen Notation

In the ORDER Relation: OrderNum is the Key.


Representing Relationships
O 1:1 Relationships. The key of one relation is stored in the second relation.
Look at example queries to determine which key is queried most often.
P 1:N Relationships.
Parent - Relation on the "1" side. Child -
Relation on the "Many" side.

Q Represent each Entity as a relation.


Copy the key of the parent into the child relation.

R CUSTOMER (CustomerID (key), Name, Address, ...)


ORDER (OrderNum (key), OrderDate, SalesPerson, CustomerID (fk))
• M:N Relationships. Many to Many relationships can not be directly implemented in
relations.
• Solution: Introduce a third Intersection relation and copy keys from original two
relations.

Chen Notation

O SUPPLIER (SupplierID (key), FirmName, Address, ...)


COMPONENT (CompID (key), Description, ...)
SUPPLIER_COMPONENT (SupplierID (key), CompID (key))

RESULT:
Thus the ER Database design using E-R model and Normalization was implemented
successfully.
Ex.No:9 FRONT END TOOLS
DATE:

Aim:

To study about the various front end tools to design forms and reports.
Examples Front End Tools:
• Visual Basic

• Visual C++

• Java

• PHP

• HTML

1. MICROSOFT VISUAL BASIC:

Visual Basic (VB) is the third-generation event-driven programming language and


integrated development environment (IDE) from Microsoft for its COM programming model.
Visual Basic is relatively easy to learn and use.
Visual Basic was derived from BASIC and enables the rapid application development (RAD) of
graphical user interface (GUI) applications, access to databases using Data Access Objects,
Remote Data Objects, or ActiveX Data Objects, and creation of ActiveX controls and objects.
Scripting languages such as VBA and VBScript are syntactically similar to Visual Basic, but
perform differently.
A programmer can put together an application using the components provided with Visual Basic
itself. Programs written in Visual Basic can also use the Windows API, but doing so requires
external function declarations.
2. MICROSOFT VISUAL C++
Microsoft Visual C++ (often abbreviated as MSVC or VC++) is a commercial (free
version available), integrated development environment (IDE) product from Microsoft for the C,
C++, and C++/CLI programming languages. It has tools for developing and debugging C++
code, especially code written for the Microsoft Windows API, the DirectX API, and the
Microsoft .NET Framework
16-bit versions
• Microsoft C 1.0, based on Lattice C, was Microsoft's first C product in 1983. It was not
K&R C.
• C 2.0 added large model support.

• C 3.0 was the first version developed inside Microsoft. It was extremely compatible with
K&R and the later ANSI standard. It was being used inside Microsoft (for Windows and
Xenix development) in early 1984. It shipped as a product in 1985.
• C 4.0 added optimizations and CodeView, a source level debugger.

• C 5.0 added loop optimizations and Huge Model (arrays bigger than 64k) support.
Microsoft FORTRAN and the first 32 bit compiler for 80386 were also part of this project.

• C 6.0 released in 1989. It added global flow analysis, a source browser, and a
new
debugger, and included an optional C++ front end.
• C/C++ 7.0 was released in 1992. It added built-in support for C++ and MFC 1.0.[2]
• Visual C++ 1.0 (original name: Visual C++ 32-bit Edition) was the first version for 32-
bit development. Although released when 16-bit 1.5 was available, it did not include
support for OLE2 and ODBC. It was also available in a bundle called Visual C++ 16/32-
bit Suite, which included Visual C++ 1.5.

• Visual C++ 2.0, which included MFC 3.0, was the first version to be 32-bit only. In many
ways, this version was ahead of its time, since Windows 95, then codenamed "Chicago",
was not yet released, and Windows NT had only a small market share. As a result, this
release was almost a "lost generation". Microsoft included and updated Visual C++ 1.5 as
part of the 2.x releases up to 2.1, which included Visual C++ 1.52, and both 16-bit and 32-
bit version of the Control Development Kit (CDK) were included. Visual C++ 2.x also
supported Win32s development. It is available through Microsoft Developer

• Visual C++ 4.0, which included MFC 4.0, was designed for Windows 95 and Windows
NT. To allow support of legacy (Windows 3.x/DOS) projects, 4.0 came bundled with the
Visual C++ 1.52 installation CD. Updates available through subscription included Visual
C++ 4.1, which came with the Microsoft Game SDK (later released separately as the
DirectX SDK), and Visual C++ 4.2. Version number 3.0 was skipped to achieve version
number parity between Visual C++ 4.0 and MFC 4.0.[9]

• Visual C++ 4.2 did not support Windows 3.x (Win32s) development.[10] This was the
final version with a cross-platform edition for the Macintosh available and it differed
from the 2.x version in that it also allowed compilation for the PowerPC instruction set.
• Visual C++ 5.0, which included MFC 4.21, was a major upgrade from 4.2.[11] Available
in four editions:
O Learning
O Professional
O Enterprise
O RISC
• Visual C++ .NET 2003 (known also as Visual C++ 7.1), which included MFC 7.1, was
released in 2003 along with.NET 1.1 and was a major upgrade to Visual C++ .NET 2002.
It was considered a patch to Visual C++ .NET 2002. Accordingly, the English language
upgrade version of Visual Studio .NET 2003 shipped for minimal cost to owners of the
English language version of Visual Studio .NET 2002. This was the last version to
support Windows 95 and NT 4.0 as a target.
Java is a programming language originally developed by James Gosling at Sun
Microsystems (now part of Oracle Corporation) and released in 1995 as a core component of Sun
Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a
simpler object model and fewer low-level facilities. Java applications are typically compiled to
byte code (class file) that can run on any Java Virtual Machine (JVM) regardless of computer
architecture. Java is a general-purpose, concurrent, class-based, object-oriented language that is
specifically designed to have as few implementation dependencies as possible.
There were five primary goals in the creation of the Java language:
1. It should be "simple, object-oriented and familiar"
2. It should be "robust and secure"
3. It should be "architecture-neutral and portable"

4. It should execute with "high performance"


5. It should be "interpreted, threaded, and dynamic"

Version
Major release versions of Java, along with their release dates:
• JDK 1.0 (January 23, 1996)
• JDK 1.1 (February 19, 1997)
• J2SE 1.2 (December 8, 1998)
• J2SE 1.3 (May 8, 2000)
• J2SE 1.4 (February 6, 2002)
• J2SE 5.0 (September 30, 2004)
• Java SE 6 (December 11, 2006)
• Java SE 7 (July 28, 2011)
Features of Java
One characteristic of Java is portability, which means that computer programs written in
the Java language must run similarly on any hardware/operating-system platform. This is
achieved by compiling the Java language code to an intermediate representation called Java byte
code, instead of directly to platform-specific machine code. Java byte code instructions are
analogous to machine code, but are intended to be interpreted by a virtual machine (VM) written
specifically for the host hardware. End-users commonly use a Java Runtime Environment (JRE)
installed on their own machine for standalone Java applications, or in a Web browser for Java
applets.

4.HTML
HTML is a language for describing web pages.
• HTML stands for Hyper Text Markup Language

• HTML is not a programming language, it is a markup language

• A markup language is a set of markup tags

HTML Tags
HTML markup tags are usually called HTML tags
• HTML tags are keywords surrounded by angle brackets like <html
• HTML tags normally come in pairs like <b> and </b>
• The first tag in a pair is the start tag, the second tag is the end tag
• Start and end tags are also called opening tags and closing tags

HTML Documents = Web Pages


• HTML documents describe web pages

• HTML documents contain HTML tags and plain text

• HTML documents are also called web pages

Result:
Thus the front-end languages visual basic, java, HTML are studied.
EX. NO: 9B FORMS- PAYROLL PROCESSING SYSTEMS
DATE:

AIM:
To implement the operations of PAYROLL PROCESSING SYSTEM using the visual
basic as front end and oracle as back end to design a forms..
PROCEDURE:
1. Collect the details of how the program is expected by the user and also the atmosphere in
which it is going to work.

2. Collect the user requirement. Develop a sketch of the program about how it is going to appear
in its final design.
3. Implement the various diagram carefully, based on which the entire project design is
going to be developed.

4. Assign the values as required by the program control settings.

5. In the component diagram, using the update code command we generate the code
for the required program.

6. Thus the program is implemented successfully.

PROGRAM:

SQL>create table emp(eno number primary key,enamr varchar(20),age


number,addr varchar(20),DOB date,phno number(10));

Table created.

SQL>create table salary(eno number,edesig varchar(10),basic number,da number,hra


number,pf number,mc number,met number,foreign key(eno) references emp);
Table created.
TRIGGER to calculate DA,HRA,PF,MC

SQL> create or replace trigger employ


2 after insert on salary
3 declare
4 cursor cur is select eno,basic from salary;
5 begin
6 for cur1 in cur loop
7 update salary set
8 hra=basic*0.1,da=basic*0.07,pf=basic*0.05,mc=basic*0.03 where hra=0;
9 end loop;
10 end;
11 /
Trigger created.

PROGRAM FOR FORM 1

Private Sub emp_Click()


Form2.Show
End Sub
Private Sub exit_Click()
Unload Me
End Sub
Private Sub salary_Click()
Form3.Show
End Sub

PROGRAM FOR FORM 2

Private Sub add_Click()


Adodc1.Recordset.AddNew
MsgBox "Record added"
End Sub
Private Sub clear_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
End Sub
Private Sub delte_Click()
Adodc1.Recordset.Delete
MsgBox "Record Deleted"
If Adodc1.Recordset.EOF = True Then
Adodc1.Recordset.MovePrevious
End If

End Sub
Private Sub exit_Click()
Unload Me
End Sub
Private Sub main_Click()
Form1.Show
End Sub
Private Sub modify_Click()
Adodc1.Recordset.Update
End Sub

PROGRAM FOR FORM 3

Private Sub add_Click()


Adodc1.Recordset.AddNew
MsgBox "Record added"
End Sub
Private Sub clear_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
End Sub
Private Sub delte_Click()
Adodc1.Recordset.Delete
MsgBox "Record Deleted"
If Adodc1.Recordset.EOF = True Then
Adodc1.Recordset.MovePrevious
End If
End Sub
Private Sub exit_Click()
Unload Me
End Sub
Private Sub main_Click()
Form1.Show

End Sub
Private Sub modify_Click()
Adodc1.Recordset.Update
End Sub

Output:
RESULT:
Thus, the payroll processing system using VB was implemented.
Ex. no: 10 DESIGN AND IMPLEMENTATION OF BANKING SYSTEM

DATE:

AIM:

To develop a banking system using Oracle as s back end(data base) and Microsoft

Visual basic6.0 as a front end.

PROCEDURE :

1. Create a banking database with the following fields in oracle


namely,acno,name,address,balance and some record into the database.

2. Design the corresponding form with labels,text boxes and command buttons.
Form1→ customer details
Form2→ withdraw

Form3→ deposit

3. Create the back with the front end using DAO method by creating a dsn as follows
a.Select administrative tools option from control panel.
Then click on data source(ODBC),which displays a dialog box named

ODBCDATASOURCESADMINISTRATOR in which click Add button.


b.In Create New Data Source dialog box,select “Microsoft ODBC for
ORACLE” and click finish button

c.Give a suitable data source name,user name and server name.

4. Perform the required operations like Insert,Delete,Searching and Exit.

5. Issue the books according to the no.of copies available.


Execute the project.
TABLE DESIGN:

Table Name :Banking

NAME TYPE
ACNO NUMBER(6)

NAME VARCHAR2(30)

ADDRESS VARCHAR2(20)

BALANCE NUMBER(8,2)

FORM 1:

Dim DB As Database

Dim RS As recordset

Private Sub Form_Load()

Set DB =OpenDatabase(“BANKDSN”,FALSE,FALSE,”ODBC;UID= ;PWD= ;”)

Set RS =DB.OpenRecordset(“select * from Bank”)

Text1.text=RS(0)

Text2.text=RS(1)

Text3.text=RS(2)

Text4.text=RS(3)

End Sub

Private Sub CLEAR_click()

Text1.text=””

Text2.text=””

Text3.text=””
Text4.text=””

End Sub

Private sub DELETE_Click()

RS.DELETE

MsgBox”the record is deleted”

RS.MoveNext IfRS.EOF

Then MsgBox”no more

records” Else

Text1.text=RS(0)

Text2.text=RS(1)

Text3.text=RS(2)

Text4.text=RS(3)

End If

End Sub

Private Sub EXIT Click()

End

End Sub

Private Sub FIRST_Click()

RS .MoveFirst

Text1.Text=RS(0)

Text2.Text=RS(1)

Text3.Text=RS(2)
Text4.Text=RS(3)

End Sub

Private Sub INSERT_Click()

RS.MoveLast

RS.AddNew

RS(0)=Text1.Text

RS(1) =Text2.Text

RS(2)=Text3.Text

RS(3)=Text4.Text

MsgBox”record is inserted”

RS.UPDATE

End Sub

Private Sub LAST_Click()

RS. MoveLast

Text1.text=RS(0)

Text2.text=RS(1)

Text3.text=RS(2)

Text4.text=RS(3)

End Sub

Private Sub NEXT_Click()

RS.Move Next

If RS.EOF Then

MsgBox”no more recfords”


Else

Text1.text=RS(0)

Text2.text=RS(1)

Text3.text=RS(2)

Text4.text=RS(3)

EndIf

End Sub

Private Sub PREVIOUS_Click()

RS.Move Previous

If RS.EOF Then

MsgBox”no more recfords”

Else

Text1.text=RS(0)

Text2.text=RS(1)

Text3.text=RS(2)

Text4.text=RS(3)

EndIf

End Sub

Private Sub UPDATE_Click()

RS.Edit

RS(0)=Text1.Text

RS(1) =Text2.Text

RS(2)=Text3.Text
RS(3)=Text4.Text

RS.UPDATE

MsgBox”record is inserted”

End Sub

Private Sub FIND_Click()

1=InputBox(“ENTER THE ACNO”,”FIND”)

rs.FindFirst”[ACNO]=”&I

If rs.NoMatch Then

MsgBox”no such records”

Else

Text1.text=RS(0)

Text2.text=RS(1)

Text3.text=RS(2)

Text4.text=RS(3)

EndIf

End Sub

Private Sub WITHDRAW_Click()

Form2.Show

End Sub

Private Sub DEPOSIT_Click()

Form3.Show

End Sub
FORM 2:

Private Sub HOMEPAGE_Click()

Form1.Show

Form2.Hide

End Sub

Private Sub WITHDRAW_Click()

Text2.Text=val(Form1.Text)-Text1.Text

Form1.Text4=Text2.text

End Sub

End

FORM 3:

Private Sub DEPOSIT_Click()

Text2.Text=val(Form1.Text)+Text1.Text

Form1.Text4=Text2.text

End Sub

Private Sub HOMEPAGE_Click()

Form1.Show

Form3.Hide

End Sub
WITHDRAW FORM:
DEPOSIT FORM:

RESULT:

Thus the banking system has been successfully developed in Visual Basic.

You might also like