SQL ASSIGNMENT- 01 G.
MEGHANA
QUESTION -01
Commands used ;
ALTER TABLE DEPARTMENT ADD CONSTRAINT DEPARTMENT
_DEPTID_PK PRIMARY KEY(DEPARTMENT_ID);
ALTER TABLE EMP02 ADD CONSTRAINT EMP02_DEPTID_FK
FOREIGN KEY(DEPARTMENT_ID) REFERENCES DEPARTMENT
(DEPARTMENT_ID);
ALTER TABLE EMP02 ADD CONSTRAINT EMP02_EMPID_PK
PRIMARY KEY(EMPLOYEE_ID)
Question - 02
Question-03 Add a column deptno with the data type no of size 4
Question- 04 Change the name of the column sal to salary
Question-05 Change the size of the column ename to 40 character long
Question-06Create a dept table with following criteria.
Dno number(6)
Dname varchar2(40)
Loc_id number (4)
Question- 07 Remove a column loc_id from dept table
Question-08 Change the name of dept to departments
Question-09 Insert into emp table the below values
Question-11 Change the salary of an employee who belong to department no
1001 to 40000
Question-13 Remove the Information of those employees who are earning
27000
Question-14 Empty the table departments
Question-15 Remove the table departments from database
Question-16 Remove the table emp from the database
Question-17 Clear the recycle bin
DROP command – Recycle bin
Question-18 Show the structure of sal_grade table
Question-19 Select all data from department table
Question-20 Show the structure of the EMPLOYEE Table
Question-21 Write a query to display the last_name, job_code, hire_date, &
empno. For each employee, with employee numbers appearing first. Provide
an alias name start date for the hire date column
Question -22 Write a query to display unique job codes from the employee
table
Question 23 Write a query to display the last name concatenated with the job
code, separated by a comma and space
Question- 24 Write a query to display the last name and salary of employees
earning more than 12000
Question – 27 Write a query to display the last name, job code and start date
of employees hired between feb 20 1998 and may 1 1998 order the query In
ascending order by start date
Question-28 Write a query to display the last name and department number
of all employees in department number 20 & 50 in alphabetical order by last
names
Question-29 Write a query to display last name and hire date of employees
who earn between 5000 to 12000 are in department of 20 or 50 label column as
employee & monthly salary
Question-30 Write a query to display the last name and hire date of all
employees who was hired in 1994
Question-31 Write a query to display the last name, salary & commission for
all employees Who earn commission. Sort data in descending order of salary
& commission
Question- 32 Write a query to display the last name of all employees Where
the third letter of the last name is an A
Question 33 Write a query to display the last name of all employees who have
an ‘A’ & ‘E’ in their last name
Question 34 Write a query to display the last name and salary whose job is
sales representative or stock clerk and whose salary is not equal to
2500,3500,7500
Question 35 Write a query to display the current date
Question-36 For each employee, display the employee number, last name &
salary and the salary increased by 15%, rename it as new salary
Question-37 For the above query add a column called increase which should
contain the difference between old & new salaries.