Ex No:1 Table Creation: Field Name Constraint Type Size
Ex No:1 Table Creation: Field Name Constraint Type Size
TABLE CREATION
Employee table:
Field name Constraint Type Size
Employee_no Primary key Character 6
Employee_name Character 30
Dob Date
Doj Date
QUERIES:
Create table employees(employee_no varchar(6)not null,emp_name varchar(30),dob date,doj
date,primary key(employee_no));
Table created.
EX NO:2
INSERT AND UPDATE
Student table:
1
3. Select the students whose name start with S.
4. Update the records.
QUERIES:
Table created.
1 row created.
1 row updated.
2
SQL> select * from classmarks;
ROLL_N STUDENT_NAME DOB EX INT
------ ------------------------------ --------- -- ---
12 siva 26-MAR-97 45 34
13 mouni 25-JUL-96 57 36
14 akil 30-MAY-54 56 38
15 sanjay 15-APR-00 58 36
16 sambath 22-JUN-65 49 33
17 salu 28-NOV-76 34 22
6 rows selected.
SQL> commit;
Commit complete.
EX NO: 3
REFERENCE KEY
Staff table:
Field name Constraint Type Size
Staff_no Primary key Character 6
Staff_name Character 30
Dob Date
Dept_code Foreign key Character 4
Designation Character 15
Basic Number 7,2
Department table:
Field name constraint Type Size
Dept_code Primary key Character 4
Dept_name Character 30
3
4. To list the maximum and minimum salary in each dept.
5. To list the dept along with the total amount spent on salary
6. To list the name of the employees who draw the salary more than the average salary.
QUERIES:
Table created
1 row created.
DPMT DPMT_NAME
---- ---------------------------
555 bcom
111 bca
222 com sci
333 inftec
444 biotec
table created
SQL> insert into stf
values('&staff_no','&staff_name','&dob','&dpmt_code','&designation','&basic');
4
SQL> select staff_name from stf where doj<sysdate-730;
STAFF_NAME
------------
meena
lakshmi
siva
SQL>select staff_name,dept_name from stf where dpmt_name=comsci;
STAFF_NAME DEPT_NAME
------------- -----------------
Mounika comsci
Siva comsci
STAFF_NAME DPMT_NAME
------------------------------ ----
meena infotec
SUM(BASIC) DPMT_CODE
---------- ----
50000 111
40000 222
SQL> select staff_name from stf where basic>=(select avg(basic)from stf);
STAFF_ STAFF_NAME DPMT BASIC
------ ----------- ------------- -------