Final Updated DBIS Record 2
Final Updated DBIS Record 2
Final Updated DBIS Record 2
Name :
Name :
Year : II Semester : IV Batch:2021 - 2025 Section :
Certified that this is the bonafide record of work done by the above student in the DATABASE
INFORMATION SYSTEMS LAB (Sub Code: U20CSCJ06) during the month June / July 2023.
Submitted for the practical Examination held on ............................................ at Bharath Institute of Higher
Education & Research, Chennai-73.
INDEX
EX. PAGE
NO. DATE TITLE NO. SIGN
3 VIEW
6 SUB QUERIES
7 JOIN QUERIES
9a PROCEDURES
9b FUNCTIONS
10 CURSORS
11 TRIGGERS
12 EXCEPTION HANDLING
Aim:
To execute DDL commands in RDBMS.
DDL commands:
✴ CREATE
✴ ALTER
✴ DROP
✴ RENAME
✴ TRUNCATE
SYNTAX’S OF COMMANDS
CREATE TABLE:
To make a new database, table, index, or stored query. A create statement in SQL
creates an object inside of a relational database management system (RDBMS).
DROP TABLE:
TRUNCATE TABLE:
Remove all records from a table, including all spaces allocated for the records are
removed.
EXERCISE:
Create Table
Table created.
DESCRIBE TABLE
EMPID
SALARY VARCHAR2 (10)
Null? Type
ALTER TABLE
Table altered.
I. ADD:
SQL> alter table employee add(designation varchar2(15));
SQL> alter table salary add(constraint nithi unique(empid));
Table altered.
II. MODIFY
Table altered.
RENAME TABLE
4 empname varchar2(20),
5 age number(3),
6 sex char
7 );
Table created.
EMPID VARCHAR2(10)
EMPNAME VARCHAR2(20)
AGE NUMBER(3)
SEX CHAR(1)
ERROR:
1 arun it 22 m
2 bala service 26 m
3 chitra sales 25 f
SQL> commit;
Commit complete.
SQL> truncate table emp;
Table truncated.
SQL> select * from emp;
no rows selected
SQL> commit;
Commit complete.
DROP TABLE
SQL> drop table empl;
Table dropped.
SQL> desc empl;
ERROR:
ORA-04043: object empl does not exist
RESULT:
Aim:
To execute DML commands in RDBMS.
DML COMMANDS:
❖ INSERT
❖ UPDATE
❖ DELETE
❖ SELECT
QUERY:
Query is a statement in the DML that request the retrieval of data from database.
❖ The portion of the DML used in a Query is called Query language. The SELECT
statement is used to query a database
SYNTAX OF COMMANDSINSERT:
Values can be inserted into table using insert commands. There are two types of insert
commands. They are multiple value insert commands (using ‘&’ symbol) single value insert
command(without using ‘&’symbol)
Syntax:
(OR)
This allows the user to update the particular column value using the where clause
condition.
Syntax:
DELETE:
This allows you to delete the particular column values using where clause condition.
Syntax:
SELECT:
The select statement is used to query a database .This statement is used to retrieve the
information from the database. The SELECT statement can be used in many ways. They are:
1. Selecting some columns :
To select specified number of columns from the table the
Following command is used.
Syntax:
To select all columns from the table * is used instead of column names.
Syntax:
The DISTINCT keyword is used to return only different values (i.e. ) this
command does not select the duplicate values from the table.
Syntax:
If you want to get the rows which contain certain values, the best way to do it
is to use the IN conditional expression.
Syntax:
BETWEEN can be used to get those items that fall within a range.
Syntax:
The select statement can be used to rename either a column or the entire
table.
Syntax:
Renaming a column:
Renaming a table:
7. Sorting:
The select statement with the order by Clause is used to sort the contents
Table either in ascending or descending order.
Syntax:
Syntax:
SELECT column name FROM table_name WHERE Column name LIKE “% or-“;
Syntax:
SELECT
Column_na me(s) INTO variable_na me(s) FROMtable_name WHERE condition.
2. To Select NULL values:
EXERCISE:
SELECT column name FROM table_name WHERE Condition1 LOGICALOPERATOR condition2;
INSERT COMMAND
SQL> insert into employee values ( ' &empid ',' &empname', '&gender',
&age, ' &dept' ,'&dob','&doj','&desig ');
Enter value for empid: acc9001
Enter value for empname: kannan
Enter value for gender: male
Enter value for age: 35
Enter value for dept: accounts
Enter value for dob: 28-dec-1975
Enter value for doj: 01-jan-1995
Enter value for desig: manager old 1:
insert into employee
values('&empid','&empname','&gender',&age,'&dept','&dob','&doj','&desi
1 row created.
1 row created.
8 rows selected.
DOJ DESIGNATION
DOJ DESIGNATION
DOJ DESIGNATION
1 row created.
8 rows selected.
1 row created.
1 row created.
SQL> select * from branchtable;
BRANCH CITY
abt maruthi chennai
UPDATE COMMAND
1 row updated.
1 row updated.
SQL> select empname,designation from employee;
EMPNAME DESIGNATION
arunprasanth manager
balakrishnan coordinator
kannan manager
magudeshwaran asst manager
jagadheesh manager
muruganandam supervisor
suresh manager
EMPNAME
arun bala
bakyarajchitra
To retrieve all columns
SQL> select * from emp;
1 arun it 22 m
2 bala accounts 26 m
3 bakyaraj stores 30 m
4 chitra sales 24 f
1 row deleted.
SQL> select * from emp;
2 bala accounts 26
m
3 bakyaraj stores 30
m
4 chitra sales 24 f
3 rows deleted.
SQL> create table student (idno number, name varchar(10),branch varchar(4));
Table created.
SQL> desc student;
IDNO NUMBER
NAME VARCHAR2(10)
BRANCH VARCHAR2(4)
IDNO NUMBER
1 ASHOK CSE BE
2 BHAVANA CSE BE
3 CAVIN CSE BE
4 DANNY IT BE
5 HARRY IT BE
1 ASHOK CSE BE
2 BHAVANA CSE BE
3 CAVIN CSE BE
4 DANNY IT B.TECH
5 HARRY IT B.TECH
RESULT:
Aim:
To write a SQL command to create a view for an existing table for security purpose
and manipulate that view table.
CREATING A VIEW:
Syntax:
The subselect is known as the defining query, if with check option is specified, SQL ensures that
if a row fails to satisfy the where clause of the getting query of the view, it is notadded to the underlying
base table of the view.
REMOVING A VIEW:
A view is removed from the database with the DROP VIEW statement.
Syntax:
If CASCADE is specified, DROP VIEW deletes all related dependent objects, all objects that
reference the view.
If RESTRICT is specified and there are any other objects that depend for their existence on the
continued existence of the view being dropped, the command is rejected. The default setting is
RESTRICT.
A horizontal view restricts a user’s access to selected rows of one or more tables. Avertical
view restricts a user’s access to selected columns of one or more tables.
UPDATABLE VIEW:
For a view to be updatable, the DBMS must be able to trace any row or column backto its row
or column in the source table.
EXERCISE
1 ASHOK CSE BE
2 BHAVANA CSE BE
3 CAVIN CSE BE
4 DANNY IT B.TECH
UPDATE VIEW
1 ASHOK CSE BE
2 BHAVANA CSE BE
3 CAVIN CSE BE
4 DANNY IT BE
SELECT
1 ASHOK CSE BE
2 BHAVANA CSE BE
3 CAVIN CSE BE
4 DANNY IT BE
DROP
SQL> drop table student;
Table dropped.
RESULT:
Aim:
To write a SQL command to create a table and apply constraints for security purpose
and manipulate it.
1 row created.
SQL> /
Enter value for idno:
Enter value for name: 'BENNY'
Enter value for branch: 'IT'
old 1: insert into staff values(&idno,&name,&branch)
new 1: insert into staff values(,'BENNY','IT')
insert into staff values(,'BENNY','IT')
*ERROR at line 1:
ORA-00936: missing expression
UNIQUE
SQL> create table employee
(
rollno number unique,
name varchar(10),
salary number
);
Table created.
FOREIGN KEY
SQL> create table admin
(
stuid number constraint stuid_pk primary key,
name varchar(10),
permit number(6)
);
Table created.
SQL> /
Enter value for stuid: 4
Enter value for name: SANJAY
Enter value for permit: 45
old 1: insert into admin values(&stuid,'&name',&permit)
new 1: insert into admin values(4,'SANJAY',45)
1 row created.
SQL> /
Enter value for stuid: 5
Enter value for name: KAMALINI
Enter value for permit: 35
old 1: insert into admin values(&stuid,'&name',&permit)
new 1: insert into admin values(5,'KAMALINI',35)
1 row created.
1 ASWIN 80
2 ROHIT 67
4 SANJAY 45
5 KAMALINI 35
SQL> /
Enter value for stuid: 2
Enter value for branch: CSE
Enter value for sec: A
old 1: insert into course values(&stuid,'&branch','&sec')
SQL> /
Enter value for stuid: 4
Enter value for branch: IT
Enter value for sec: A
old 1: insert into course values(&stuid,'&branch','&sec')
new 1: insert into course values(4,'IT','A')
1 row created.
SQL> /
Enter value for stuid: 6
Enter value for branch: CSE
Enter value for sec: A
old 1: insert into course values(&stuid,'&branch','&sec')
new 1: insert into course values(6,'CSE','A')
insert into course values(6,'CSE','A')
*
ERROR at line 1:
ORA-02291: integrity constraint (SCOTT.SID_FK) violated - parent key not found
1 ASWIN 80
2 ROHIT 67
4 SANJAY 45
SQL> select * from course;
STUID BRANCH SE
1 CSE A
2 CSE A
4 IT A
RESULT:
DATE:
Aim:
To execute DCL commands in RDBMS.
DCL commands:
CREATE
GRANT
REVOKE
CREATE USER
Syntax:
CREATE USER <user_name> IDENTIFIED BY <password>;
Example:
SQL> create user system identified by cse;
User created.
GRANT COMMAND
Syntax:
GRANT ALL PRIVILEGES TO <user_name>;
Example:
SQL> conn
Enter user-name:system
Enter password: ***
Connected.
REVOKE COMMAND
Syntax:
Example:
RESULT:
Aim:
To write SQL queries for retrieving data from a relation(s) using sub queries and joins.
EXERCISE:
SQL> create table employee1(empno number(10), empname varchar(10), dept char(10), salary
number(10));
Table created.
1 row created.
SQL> /
Enter value for empno: 101
Enter value for empname: ramu
Enter value for dept: testing
Enter value for salary: 45000
old 1: insert into employee1 values(&empno,'&empname','&dept',&salary)
new 1: insert into employee1 values(101,'ramu','testing',45000)
1 row created.
SQL> /
Enter value for empno: 103
Enter value for empname: rajesh
Enter value for dept: network
Enter value for salary: 35000
old 1: insert into employee1 values(&empno,'&empname','&dept',&salary)
new 1: insert into employee1 values(103,'rajesh','network',35000)
1 row created.
SQL> /
Enter value for empno: 104
Enter value for empname: ramya
Enter value for dept: testing
Enter value for salary: 10000
old 1: insert into employee1 values(&empno,'&empname','&dept',&salary)
new 1: insert into employee1 values(104,'ramya','testing',10000)
1 row created.
SQL> /
Enter value for empno: 105
Enter value for empname: ramesh
Enter value for dept: network
Enter value for salary: 60000
old 1: insert into employee1 values(&empno,'&empname','&dept',&salary)
new 1: insert into employee1 values(105,'ramesh','network',60000)
1 row created.
❖ Single join
❖ Self join
❖ Outer join
❖ Natural join
SINGLE JOIN:
It retrieves rows from two tables having a common column. it is further classified into
equi-join and non equi-join.
Equi join:
A join which is based on equalities, is called an equai-join combines rows that have
equivalent values for the specified columns.
Non equi-join
A non equi join specifies the relationship between column belonging to diff tables by
making use of the relational operation (>, <, <=,>=, <>) other than =.
NATURAL JOIN:
The equijoin must produce a result containing two identical columns. If one of these
columns is eliminated, then that join is called the “natural join
NAME DEPT
ANTON CSE
DHARUN EEE
FELTON CSE
GEENA MECH
HARRY ECE
SELF JOIN:
NAME DEPT
ANTON CSE
FELTON CSE
OUTER JOIN:
When tables are joined rows, which contain matching values in the join predicates are
returned. Sometimes, matching and non –matching rows returned for the tables that are being
joined.
The outer join can be
❖ Left outer
❖ Right outer
❖ Full outer
LEFT OUTER JOIN retains non-matching rows from the left table in the result and place
null values in the attributes that comes from the right table. RIGHT OUTER JOIN retains
non-matching attributes from the right table and FULL OUTER JOIN of that retains non-
matching attributes from both tables.
INNER JOIN
SQL> select employee.empid, employee.dept from employee inner join salary on
employee.empid=salary.empid;
EMPID DEPT
it9001 it
it9002 it
acc9001 accounts
acc9002 accounts
ser9001 service
ser9006 service
sal9001 sales
sal9006 sales
8 rows selected.
EMPID DEPT
it9001 it
it9002 it
acc9001 accounts
acc9002 accounts
ser9001 service
ser9006 service
sal9001 sales
sal9006 sales
8 rows selected.
EMPID DEPT
-
it9001 it
it9002 it
acc9001 accounts
acc9002 accounts
ser9001 service
ser9006 service
sal9001 sales
sal9006 sales
8 rows selected.
it9001 it it
it9002 it it
acc9001 accounts it
acc9002 accounts it
ser9001 service it
ser9006 service it
sal9001 sales it
sal9006 sales it
it9001 it it
it9002 it it
acc9001 accounts it
acc9002 accounts it
ser9001 service it
ser9006 service it
sal9001 sales it
sal9006 sales it
it9001 it accounts
it9002 it accounts
acc9001 accounts accounts
acc9002 accounts accounts
ser9001 service accounts
ser9006 service accounts
sal9001 sales accounts
sal9006 sales accounts
it9001 it accounts
it9002 it accounts
acc9001 accounts accounts
acc9002 accounts accounts
ser9001 service accounts
ser9006 service accounts
sal9001 sales accounts
sal9006 sales accounts
it9001 it service
it9002 it service
acc9001 accounts service
acc9002 accounts service
ser9001 service service
ser9006 service service
sal9001 sales service
sal9006 sales service
it9001 it service
it9002 it service
acc9001 accounts service
acc9002 accounts service
ser9001 service service
ser9006 service service
sal9001 sales service
sal9006 sales service
it9001 it sales
it9002 it sales
acc9001 accounts sales
acc9002 accounts sales
ser9001 service sales
ser9006 service sales
sal9001 sales sales
sal9006 sales sales
it9001 it sales
it9002 it sales
EMPNAME
arunprasanth
balakrishnan
kannan
magudeshwaran
jagadheesh
muruganandam
suresh
sharmila
8 rows selected.
SQL> select e.empname, s.salary from employee e, salary s where e.empid= s.empid and
salary>10000;
EMPNAME SALARY
arunprasanth 35000
balakrishnan 18000
kannan 35000
magudeshwaran 26000
jagadheesh 35000
muruganandam 12000
suresh 40000
sharmila 17000
8 rows selected.
balakrishnan chennai
suresh chennai
sharmila chennai
3 rows selected.
EMPNAME DEPT
-
kannan accounts
magudeshwaran accounts
arunprasanth it
balakrishnan it
suresh sales
sharmila sales
jagadheesh service
muruganandam service8 rows selected.
RESULT:
Aim :
To implement sequences and synonyms in SQL
Syntax:
create sequence <sequence_name>
start with <value>
minvalue <value>
increment by <value>
maxvalue <value>
cycle/nocycle;
EXERCISE:
SQL> create sequence my_seq1
start with 1
minvalue 1
increment by 1
maxvalue 5
nocycle;
Sequence created.
Table created.
Table created.
SQL> insert into xyz values(my_seq1.nextval);
1 row created.
1 row created.
1 row created.
EMPNO
3
SQL> insert into xyz1 values(my_seq1.nextval);
1 row created.
EMPNO
3
4
1 row created.
EMPNO
3
4
5
CURRVAL
5
SYNONYMS:
An alias or alternative names can be given to anyof the database objects like a table, view, stored procedure,
user-defined function, and sequence with the help of SQL Server Synonym.
Syntax:
1. CREATE SYNONYM [ name_of_schema. ] name_of_synonym
2. FOR name_of_base_object;
Table created.
SQL> CREATE SYNONYM fruit for fruits;
Synonym created.
no rows selected
no rows selected
SQL> select * from fruit;
FRUIT_NAME
QUANTITY
mango
3
FRUIT_NAME
QUANTITY
mango
3
RESULT:
EX.NO:9a PROCEDURES
DATE:
Aim:
To implement PL/SQL program using procedures.
SQL> create table stud(rno number(2), mark1 number(3), mark2 number(3), total number(3), primary
key(rno));
Table created.
SQL> desc stud;
Name Null? Type
1 80 85 0
2 75 84 0
3 65 80 0
4 90 85 0
SQL> create or replace procedure student (rnum number) is
2 m1 number;
3 m2 number;
4 total number;
5 begin
6 select mark1,mark2 into m1,m2 from stud where rno=rnum;
7 if m1<m2 then
8 update stud set total=m1+m2 where rno=rnum;
9 end if;
10 end;
1 80 85 165
2 75 84 0
3 65 80 0
4 90 85 0
SQL> exec student(4);
PL/SQL procedure successfully completed.
SQL> select * from stud;
RNO MARK1 MARK2 TOTAL
1 80 85 165
2 75 84 0
3 65 80 0
4 90 85 0
1 80 85 165
2 75 84 159
3 65 80 145
4 90 85 0
RESULT:
Aim:
To implement PL/SQL program using functions.
1 80 65 0
2 77 56 0
3 89 90 0
145
133
179
RESULT:
AIM:
To study and execute cursor program in PL/SQL to fetch and manipulate the data.
SQL> declare
2 cempid cur_salary.empid%type;
3 cname cur_salary.empname%type;
4 cdept cur_salary.dept%type;
5 csalary cur_salary.salary%type;
6 coldsalary cur_salary.salary%type;
7 cursor c is select empid,empname,dept,salary from cur_salary where dno=&dno;
8 begin
9 open c;
10 loop
11 fetch c into cempid,cname,cdept,csalary;
12 exit when c%notfound;
13 update cur_salary set salary=csalary+csalary*0.05 where empid=cempid and salary>25000;
14 select salary into csalary from cur_salary where empid=cempid;
15 dbms_output.put_line('cempid'||''||'cname'||''||''||'old_salary='||''||'New Salary');
16 dbms_output.put_line(cempid||''||cname||''||to_char(coldsalary)||''||to_char(csalary));
17 end loop;
18 close c;
19 end;
20 /
Enter value for dno: 33
old 7: cursor c is select empid,empname,dept,salary from cur_salary where dno=&dno;
new 7: cursor c is select empid,empname,dept,salary from cur_salary where dno=33;
cempidcnameold_salary=New Salary
sal8001kumaresan31500
PL/SQL procedure successfully completed.
RESULT:
Aim:
TRIGGER:
A database trigger is a stored procedure that is fired when an insert, update or delete statement is issued
against the associated table. Database triggers can be used for the following purposes.
➢ To generate data automatically.
➢ To enforce complex integrity constraints. (e.g. Checking with sysdate, checking with data in
another table).
➢ To customize complex security authorizations.
➢ To maintain replicate tables.
➢ To audit data modifications.
PARTS OF A TRIGGER
A database trigger has three parts, namely, a trigger statement, a trigger body and a trigger
restriction.
TRIGGER STATEMENT:
A trigger statement specifies the DML statements like update, delete and insert and it fires the
trigger body. It also specifies the table to which the trigger is associated.
TRIGGER BODY:
EXERCISE:
1. Write a PL/SQL program to create a trigger before the user inserts the data into the table.
2. Write a PL/SQL program to create a trigger before the user deletes the data from the table.
3. Write a PL/SQL program to create a trigger before the user changes the value of the salaryof the employee.
ANSWERS:
SQL>create or replace trigger ins1 before insert on emp
begin
Department of Computer Science and Engineering, School of Computing
U20CSCJ06 – Database Information Systems Laboratory
raise_application_error (-20001,'you can’t insert a row');
end;
OUTPUT:
SQL>insert into emp values(&eid,'&name','&dob','&addr','&sex','&desig',&deptno,'&maritsta',&salary);
SQL>insert into emp *
values(&eid,'&name','&dob','&addr','&sex','&desig',&deptno,'&maritsta',&salary);
ERROR at line 1:
ORA-20001: you cant insert a row
ORA-06512: at "CSE382.ins1", line 2
ORA-04088: error during execution of trigger 'CSE382.ins1'
OUTPUT:
SQL>delete from emp where eid=4444;
delete from emp where eid=4444;
*
ORA-20001: you can’t delete a row
ORA-06512: at "CSE382.DEL1", line 2
ORA-04088: error during execution of trigger 'CSE382.DEL1'
SQL> create trigger upd1 before update on emp for each row
2 begin
3 if :new.sal < 1000 then
4 raise_application_error(-20001,'salary can’t be low than this');
5 end if;
6 end;
7/
Trigger created.
RESULT:
Aim:
PREDEFINED EXCEPTIONS:
DECLARE
E EMP%ROWTYPE;
BEGIN
SELECT * INTO E FROM EMP WHERE DEPTNO=&DEPTNO;
DBMS_OUTPUT.PUT_LINE(E.EMPNO||' '||E.ENAME||' '||E.JOB||' '||E.SAL||' '||E.DEPTNO);
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE(' NO EMPLOYEES ARE WORKING WITH EMPLOYEE
NUMBER');
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE(' MORETHAN ONE EMPLOYEE EXISTS ');
END;
1 row created.
1 row created.
EMPNO ENAME
111 sai
Manager 50000 11
122 anu
clerk 20000 12
122 abi
clerk 20000 12
EMPNO ENAME
122 abi
clerk 20000 12
122 abi
clerk 20000 12
SQL> /
Enter value for deptno: 13
old 4: SELECT * INTO E FROM EMP WHERE DEPTNO=&DEPTNO;
new 4: SELECT * INTO E FROM EMP WHERE DEPTNO=13;
NO EMPLOYEES ARE WORING WITH EMPLOYEE NUMBER
SQL> /
SQL> DECLARE
VALUE_MISSING EXCEPTION;
A NUMBER(2):=&A;
B NUMBER(2):=&B;
C NUMBER(4);
BEGIN
IF A IS NULL OR B IS NULL THEN
RAISE VALUE_MISSING; -- CALLING EXCEPTION
END IF;
C:=A+B;
DBMS_OUTPUT.PUT_LINE('ADD OF TWO NUMBERS : '||C);
EXCEPTION
WHEN VALUE_MISSING THEN
DBMS_OUTPUT.PUT_LINE(' COLUMN VALUES ARE MANDATORY ');
END;
/
SQL> /
Enter value for a: 10
old 3: A NUMBER(2):=&A; new
3: A NUMBER(2):=10;
Enter value for b: 20
old 4: B NUMBER(2):=&B; new
4: B NUMBER(2):=20;ADD OF
TWO NUMBERS : 30
RESULT:
EX.NO:13
DATE:
CASE STUDY USING REAL LIFE DATABASE APPLICATIONS
Aim:
To create a simple calculator using Jframe (Netbeans IDE)
Implementation:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String n1= jTextField1.getText();
String n2= jTextField2.getText();
int num1=Integer.parseInt(n1);
int num2=Integer.parseInt(n2);
int res=num1+num2;
jTextField3.setText(res+"");
RESULT:
EX.NO:14
DATE:
Database connectivity with Front & Back End Tools
Aim:
To implement database connectivity with front and back end tools.
Implementation:
Source Code:
Select Query:
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
{
System.out.println(e);
}
Insert
try
{
System.out.println(e);
}
Update
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
//step2 create the connection object
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","cse2");
//step3 create the statement object
Statement stmt=con.createStatement();
//step4 execute query
int x=stmt.executeUpdate("update emp set sname='siva' where sno=333");
System.out.println(x+" row updated");
con.close();
}catch(Exception e)
{
System.out.println(e);
}
Delete
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
//step2 create the connection object
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","cse2");
//step3 create the statement object
Statement stmt=con.createStatement();
//step4 execute query
int x=stmt.executeUpdate("delete from emp where sno=333");
System.out.println(x+" row deleted");
con.close();
}catch(Exception e)
{
System.out.println(e);
}
RESULT: