0% found this document useful (0 votes)
2 views

SQL Query Assignement

Query assignment

Uploaded by

Deepak Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL Query Assignement

Query assignment

Uploaded by

Deepak Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

ORACLE ASSIGNEMENT -1

 Create the customer table having following entities make cust_id field as
a primary key.
cust_id Name Address Doj

1 Ram Delhi '30-aug-85'

2 Sham Rohtak '30-jun-86'

3 Rohan Gujrat '30-may-87'

4 Rajan Rohtak '30-may-88'

 View all the data of customer table

 Retrieve only first two records from the customer table.

 View all the data of customer table whose address is sirsa

 View all the data of customer table whose address is not 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';

 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’.

 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

 Retrieve the unique address from the customer table.

 Delete the record of customer table whose name is ram.

 Delete all the record of customer table

 Delete the customer table

ORACLE ASSIGNMENT -2
 Create table emp(id numeric(10), salary numeric(10), name varchar(60));

 Insert into emp values (1, 5000, ‘ram’);


 Insert into emp values (2, 6000, ‘sham’);
 Insert into emp values (3, 5000, ‘mohan’);
 Insert into emp values (4, 5000, ‘karan’);

 Count the total number of records in the emp table.

 Calculate the total salary from emp table

 Calculate the average of salary from emp table

 Calculate the maximum salary from emp table.

 Calculate the minimum salary from emp table

 Retrieve all the records of emp table whose salary is maximum.

 Change the case of name field in upper letter.

 Change the case of name field in lower letter.

 Add the column of address in the emp table using alter command

 Delete the column of address in the emp table

 Change the Data Type of name column in the emp table.

 Retrieve the data from two different tables with help of union command.
(NOTE: FOR THIS COMMAND BOTH THE TABLE MUST HAVE SAME
NUMBER OF FIELDS AND MUST HAVE SAME DATATYPE)

 Create table stud id numeric(10), name varchar(50). Make id as unique


key

 Create table supplier s_id numeric(10), s_name varchar(50), address


varchar(50). Make s_id as primary key
 Create table customer c_id numeric(10), c_name varchar(50), address
varchar(50), s_id numeric(10). Make s_id as primary key and s_id as
foreign key.

 Retrieve all the data from customer and supplier tables.

 Show the name field records with any other alias name

 Delete all the data from student table using truncate command

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 the table name RI having fild id, name. In this table name should
be ram. (Use Check Command)

 Use the table’s supplier & customer from the assignment no 2 and show
the working of inner join.

 Use the table’s supplier & customer from the assignment no 2 and show
the working of left join.

 Use the table’s supplier & customer from the assignment no 2 and show
the working of right join.
 Use the table’s supplier & customer from the assignment no 2 and show
the working of full outer join.

 Use the table’s supplier & customer from the assignment no 2 and show
the working of self join.

 Create a view of supplier with the new name supp.

 Insert the values in the supp table

 Delete any data from supp table.

 Drop the view supp

 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);

 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.

 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 all the data from math table where name having not null values.

 Show the schema of math table.

 Rename the math table to new name math1


 Create table student(id numeric(10), name varchar(40));

 Create table s_id(stud_id numeric(10), name varchar(40));

Insert into student values(1, ‘raju’);


Insert into student values(2, ‘ram’);
Insert into student values(3, ‘raman’);
Insert into student values(4, ‘rohit’);

Insert into s_id values(1, ‘ram’);


Insert into s_id values(2, ‘raman’);
Insert into s_id values(3, ‘amit’);

 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.

You might also like