DBMS SK File
DBMS SK File
OF
B.TECH
IN
COMPUTER SCIENCE
ENGINEERING
Submitted by Submitted to
8 Write SQL queries for extracting data from more than one table
Using two tables create a view, which shall perform natural join, equi
11
join, outer joins.
Write a procedure for computing income tax of employee on the basic
of following conditions:-
a. if gross pay<=40,000 then I.T rate is 0%.
12
b. if gross pay>40,000 but <60000 then I.T rate is 10%.
c. if gross pay>60,000 but <1,00,0000 then I.T rate is 20%.
d. if gross pay>1,00,0000 then I.T rate is 30%.
Write trigger for before and after insertion, deletion and updation
13
process.
Write SQL queries to make procedure to find area of circle and insert
14
in a table
2| 1223368
PROGRAM NO. 1
AIM:- Write the queries for Data Definition Language (DDL) in RDBMS
CREATE Command:
The CREATE command is used to create new database in DBMS, and create new table in database. In other
word we can say CREATE command used to create new database and table.
Syntax:
CREATE TABLE table_name
(
column1 data_type(size), column2
data_type(size), column3
data_type(size),
....
);
ALTER command:
The definition of a base table or of other named schema elements can be changed using the ALTER
command. After creating a table we may need to change the table structures because we omit a column or
our column definition needs to be changed. For this purpose, we use Alter Command.
Syntax:
AlterTable <TableName>Add(<ColumnName><Datatype>(<size>));
3| 1223368
TRUNCATE Command:
This only deletes the data present in the table .
Syntax
truncate table <table name>;
DROP Command:
This delete complete table with data Table dropped.
syntax
drop table <table name>;
4| 1223368
PROGRAM NO. 2
AIM:- Write the queries for Data Manipulation Language (DML) n RDBMS.
INSERT Command:
The INSERT INTO statement of SQL is used to insert a new row in a table.
Syntax
INSERT INTO table_name VALUES (value1, value2, value3,...);
UPDATE Command:
The UPDATE statement in SQL is used to update the data of an existing table in database.
Syntax
UPDATE TableName
SET column_name1 = value, column_name2 = value....
WHERE condition;
5| 1223368
DELETE Command:
The DELETE Statement in SQL is used to delete existing records from a table.
Syntax
DELETE FROM table_name WHERE some_condition;
6| 1223368
PROGRAM NO. 3
AIM:- Write the queries for Data Control Language (DCL) in RDBMS.
GRANT Command:
SQL GRANT is a command used to provide access or privileges on the database objects to the users.
Syntax
GRANT SELECT privilege_list ON table_name TO SYSTEM;
REVOKE Command:
The REVOKE command removes user access rights or privileges to the database objects.
Syntax:
7| 1223368
PROGRAM NO. 4
INTEGRITY CONSTRAINTS:
Integrity constraints ensure that the data insertion, updating, and other processes have to be performed in
such a way that data integrity is not affected.
8| 1223368
9| 1223368
PROGRAM NO. 5
10 | 1223368
c. Like predicate for pattern matching in database
11 | 1223368
PROGRAM NO. 6
AIM:- Write SQL query using character, number and group function
CHARACTER FUNCTION:-
concat:-
substr:-
instr:-
12 | 1223368
rpad:-
rtrim:-
upper:-
NUMBER FUNCTION:-
abs:-
13 | 1223368
ceil:-
mod:-
sign:-
sqrt:-
DATE FUNCTION:-
add_months:-
14 | 1223368
GROUP FUNCTION:-
count:-
Distinct:-
max:-
sum:-
15 | 1223368
PROGRAM NO. 7
PROJECTION operation:
It selects only those columns or attributes in which the user is interested and discards other.
SELECTION operation:
It is used to select the subset of the tuples of a relation that satisfies theselection condition.
RENAME operation:
This operation is used to rename the output relation for any operation which returns result like select,project
etc. or to simply rename a relation.
16 | 1223368
UNION operation:
It is used to combine the results of two or more Select statements.However, it will eliminate duplicate rows
from its result set. In case of union, number ofcolumns and data type must be same in both the tables.
INTERSECTION operation:
It is used to combine two SELECT statements, but it onlyreturns the records which are common from both
SELECT statements.
MINUS operation:
17 | 1223368
CROSS JOIN operation:
The CROSS JOIN keyword returns all records from both tables (table1 and table2).
Natural join is an SQL join operation that creates a join on the base of the common columns in the tables.
18 | 1223368
PROGRAM NO. 8
AIM:- Write SQL queries for extracting data from more than one table
19 | 1223368
NATURAL JOIN operation:
20 | 1223368
LEFT OUTER JOIN operation:
21 | 1223368
PROGRAM NO. 9
22 | 1223368
PROGRAM NO. 10
ROLLBACK:
The ROLLBACK command is the transactional command used to undo transactions that have not already
been saved to the database. The ROLLBACK command can only be used to undo transactions since the
last COMMIT or ROLLBACK command was issued.
Syntax
Rollback;
COMMIT:
The COMMIT command is the transactional command used to save changes invoked by atransaction to the
database. The COMMIT command saves all transactions to the database since the
lastCOMMITorROLLBACKcommand.
Syntax:
Commit;
23 | 1223368
24 | 1223368
PROGRAM NO. 11
AIM:- Using two tables create a view, which shall perform natural join, equi join, outer joins.
25 | 1223368
PROGRAM NO. 12
AIM:- Write a procedure for computing income tax of employee on the basic of following
conditions:-
a. if gross pay<=40,000 then I.T rate is 0%.
b. if gross pay>40,000 but <60000 then I.T rate is 10%.
c. if gross pay>60,000 but <1,00,0000 then I.T rate is 20%.
d. if gross pay>1,00,0000 then I.T rate is 30%.
26 | 1223368
27 | 1223368
PROGRAM NO. 13
AIM:- Write trigger for before and after insertion, deletion and updation process.
28 | 1223368
PROGRAM NO. 13
AIM:- Write SQL queries to make procedure to find area of circle and insert in a table.
29 | 1223368
PROGRAM NO. 15
AIM:- Write a program in PL/SQL using after update or delete using Triggers.
30 | 1223368