Deepak SQL Query Assignement
Deepak SQL Query Assignement
Deepak SQL Query Assignement
PRACTICAL FILE
(2022-2025)
SUBMITTED BY:
DEEPAK YADAV
ENROLLMENT NO.:
01913401922
UNDER THE GUIDANCE OF
1
ACKNOWLEDGEMENT
DEEPAK YADAV
2
ORACLE ASSIGNEMENT -1
● Create the customer table having following entities make cust_id field as
a primary key.
cust_id Name Address Doj
● View all the data of customer table whose address is not Sirsa
3
SELECT * FROM customer WHERE Address <> ‘Sirsa’;
● View cust_id and name from customer table whose doj is ’30-may-88’
● View all the data of customer table whose doj is greater then ‘30-may-87’
● View all the records of customer table whose address is rohtak and
cust_id=2
● View all the records of customer table whose name is rohan or doj is ‘30-
may-87’
● View all the data of customer table whose doj is between '30-may-85' and
'17-nov-86';
● View all the data of customer table whose doj is not between '30-may-85'
and '17-nov-86';
4
SELECT * FROM customer WHERE Doj NOT BETWEEN '30-may-85' AND
'17-nov-86';
● View all the records of customer table where the address can be delhi,
gujrat, sirsa.
● Update the address of customer table whose cust_id=4 with new address
‘sirsa’
● Update the name & address of customer table whose cust_id=2 with new
name & address.
● View all the records of customer whose name starting with char ‘r’.
● View all the records of customer whose name starting with Any letter but
second and third letter is ‘am’.
5
● View all the records of customer whose name starting and ending letter is
anything but this two letter ‘am’ should be in between the name.
● View all the data of customer table & their address should be in ascending
order.
● View all the data of customer table thier address should be in descending
Order
6
ORACLE ASSIGNMENT -2
● Add the column of address in the emp table using alter command
● Retrieve the data from two different tables with help of union command.
8
(NOTE: FOR THIS COMMAND BOTH THE TABLE MUST HAVE SAME
NUMBER OF FIELDS AND MUST HAVE SAME DATATYPE)
9
● Show the name field records with any other alias name
● Delete all the data from student table using truncate command
10
ORACLE ASSIGNMENT -3
● Create the table name PO having fild id, name, score. In this table id
should be greater then 0. (Use check command)
CREATE TABLE PO (
id INT CHECK (id > 0),
name VARCHAR(50),
score INT
);
● Create the table name RI having fild id, name. In this table name should
be ram. (Use Check Command)
CREATE TABLE RI (
id INT,
name VARCHAR(50) CHECK (name = 'ram')
);
● Use the table’s supplier & customer from the assignment no 2 and show
the working of inner join.
SELECT *
FROM supplier
INNER JOIN customer ON supplier.s_id = customer.s_id;
11
● Use the table’s supplier & customer from the assignment no 2 and show
the working of left join.
SELECT *
FROM supplier
LEFT JOIN customer ON supplier.s_id = customer.s_id;
● Use the table’s supplier & customer from the assignment no 2 and show
the working of right join.
SELECT *
FROM supplier
RIGHT JOIN customer ON supplier.s_id = customer.s_id;
● Use the table’s supplier & customer from the assignment no 2 and show
the working of full outer join.
SELECT *
FROM supplier
FULL OUTER JOIN customer ON supplier.s_id = customer.s_id;
● Use the table’s supplier & customer from the assignment no 2 and show
the working of self join.
SELECT *
FROM table_name AS t1
JOIN table_name AS t2 ON t1.column_name = t2.column_name;
12
CREATE VIEW supp AS
SELECT * FROM supplier;
● Create the table of name math having field name & salary.
Insert into math values('rakesh',5000);
Insert into math values('rakesh',3000);
Insert into math values('saurav',4000);
Insert into math values('saurav',7000);
13
● From the above data find the total salary of rakesh & saurav using group
by command
● Retrieve the data from the math table where name of person is ‘raju’
using having command.
SELECT *
FROM math
HAVING name = 'raju';
● Retrieve the data from the math table where the total salary of
any person is greater then 10000 using having command.
(Note: The WHERE clause places conditions on the selected columns, whereas
the HAVING clause places conditions on groups created by the GROUP BY
clause. The HAVING clause must follow the GROUP BY clause in a query and
must also precede the ORDER BY clause if used. )
● Select all the data from math table where name having null values.
SELECT *
FROM math
WHERE name IS NULL;
14
● Select all the data from math table where name having not null values.
SELECT *
FROM math
WHERE name IS NOT NULL;
DESCRIBE math;
15
● Select the value from both student & s_id table using Union Command.
● Use the minus command in the above tables student & S_id & Show the
result.
● Use the Interect command in the above tables student & S_id & Show the
result.
16