Vous êtes sur la page 1sur 10

Que) Create a table employee with following attributes: Emp_id number(6) Emp_name varchar(25) dep_id number(2) Salary number(8)

Insert 5 records in it. Insert into employee value(1,manjula,12,20000) (i)Display all the employees details. SELECT * FROM EMPLOYEE34 (ii)Display the no.of employess. SELECT COUNT(*) FROM EMPLOYEE34 (iii)Display avg salary of all employee. SELECT AVG(SALARY) FROM EMPLOYEE34 (iv)Display the maximum salary. SELECT MIN(SALARY) FROM EMPLOYEE34 (v)Display the minimum salary. SELECT MAX(SALARY) FROM EMPLOYEE34

Que) Create a table employee with following attributes: Emp_id number(6) Emp_name varchar(25) Emp_id number(2) Salary number(8) Address varchar(10) (i)Add one more field DOB. ALTER TABLE EMPLOYEE34 ADD(DOB DATE) (ii)Modify name field to varchar. ALTER TABLE EMPLOYEE MODIFY EMP_NAME VARCHAR(40) (iii)Update name to rajesh where id=1. UPDATE EMPLOYEE SET EMP_NAME=RAJESH WHERE EMP_ID=1 (iv)Delete employee details where id-4. DELETE EMPLOYEE34 WHERE EMP_ID=4 (v)Delete address field from the table. ALTER TABLE EMPLOYEE34 DROP(ADDRESS)

Que) Create a table temperature with following attributes: Id number(3) City varchar1 Max_temp number(2) Min_temp number(2) Insert minimum 7 records in it. (i) Display maximum temperature for all city. SELECT CITY,MAX_TEMP MAXIMUM_TEMPERATURE FROM TEMP (ii) Display minimum temperature for all city. SELECT CITY,MIN_TEMP MINIMUM_TEMPERATURE FROM TEMP (iii) Display the record where maximum temperature is between 30 to 40. SELECT * FROM TEMP WHERE MAX_TEMP BETWEEN 30 AND 40. (iv) Display record where minimum temperature is less than 20. SELECT * FROM TEMP WHERE MIN_TEMP <20.

Que) Create a table book with following attributes: Book_id number(2) Book_title varchar(20) Book_authur varchar(20) Book_publisher varchar(20) Price number(4) No_of_pages number(3) Edition number(1) Insert 7 proper records. (i) Find the names of all the books published by abc publication. SELECT * FROM BOOK WHERE BOOK_PUBLISHER=ABC (ii)Find the names of publisher which are distinct. SELECT DISTINCT BOOK_PUBLISHER FROM BOOK (iii)Find the name of the book which has maximum price. SELECT MAX(PRICE) FROM BOOK (iv)Find the total price of all the books. SELECT SUM(PRICE) FROM BOOK (v)List the id and books titles of all the books written by a publisher. SELECT BOOK_ID,BOOK_TITLE BOOK_PUBLISHER=ABC FROM BOOK WHERE

(vi)Find the edition of the books with the title dbms. SELECT EDITION FROM BOOK WHERE BOOK_TITLE=DBMS

Que) Create a table employee with following attributes: Id number(3) City varchar1 Max_temp number(2) Min_temp number(2) Insert minimum 7 records in it. Create primary key as id. Create city as unique key. (i)Add +5 to the maximum temperature field. SELECT MAX_TEMP +5 AS NEW_TEMPERATURE FROM TEMP (ii)Display the city name where the max_temp is 26,29,28 & 30. SELECT CITY IN(26,29,28,30) FROM TEMPERATURE WHERE MAX_TEMP

(iii)Display the city name that starts with the alphabet d. Select city from temp where city like d% (iv)Find the maximum, minimum temperature off all the CITY. SELECT MAX_TEMP,MIN_TEMP FROM TEMP (v)List the no. of city in your table. SELECT COUNT(CITY) FROM TEMP

Que) Create a table employee with following attributes: Emp_id number(6) Emp_name varchar(25) Salary number(8) Address varchar(10) Dep_name varchar(10) Insert 5 records in it. (i)Find the sum of the salary in hr department. SELECT SUM(SALARY) FROM EMPLOYEE WHERE DEP_NAME=HR (ii)Find out department. the total salary and group them by

SELECT SUM(SALARY) FROM EMPLOYEE GROUP BY DEP_NAME (iii)Find the average salary of each department. List only which having salary>30,000. SELECT AVG(SALARY) FROM EMPLOYEE GROUP BY DEP_NAME HAVING SUM(SALARY)>30000 (iv)Display employee details in ascending order by name. SELECT * FROM EMPLOYEE ORDER BY EMP_NAME DESC (v)Display employee details in descending order by name. SELECT * FROM EMPLOYEE ORDER BY EMP_NAME ASC (vi)Delete the emp_name field ALTER TABLE EMPLOY DROP(EMP_NAME) (vii)Add two fields naming first name and last name. ALTER TABLE EMPLOYEE ADD

(F_NAME VARCHAR(12) L_NAME VARCHAR(12)) (viii)Add values in it. UPDATE EMPLOYEE WHERE EMP_ID=1 SET F_NAME=MANJULA,L_NAME=ARYA

(ix)Concatenate first name nad last name. SELECT F_NAME || L_NAME AS NAME FROM EMOPLOYEE

Que) Create two tables customer and order with following attributes: Cust_id number(2) Cust_name varchar(23) ord_id number(2) ord_name varchar(23) Insert 5 records in it.

Que) Create a table max_function with following attributes: A float(4) B float(4) Insert 5 records in it. Perform the following function: Abs Ceil Floor Mod Pow Sqrt Round (I)SELECT ABS(A) FROM MAX_FUNCTION (II)SELECT CEIL(A) FROM MAX_FUNCTION (III)SELECT FLOOR(A) FROM MAX_FUNCTION (IV)SELECT MOD(A,B) FROM MAX_FUNCTION (V)SELECT POWER(4,2) FROM MAX_FUNCTION (VI)SELECT SQRT(900) FROM MAX_FUNCTION (VII)SELECT ROUND(A) FROM MAX_FUNCTION

Que) Create two tables naming table_1 and table_2 having the following attributes: Emp_id number(2) Emp_name varchar(4) Insert 5 records in it. Perform the following function: Union Intersection Difference (I)SELECT * FROM TABLE_1 UNION SELECT * FROM TABLE_2 (II)SELECT * FROM TABLE_1 INTERSECT SELECT * FROM TABLE_2 (III)SELECT * FROM TABLE_1 MINUS SELECT * FROM TABLE_2

Vous aimerez peut-être aussi