Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 3

QUESTION 1)

Create a table EMPLOYEE with following schema:

(Emp_no, E_name, E_address, E_ph_no, Dept_no, Dept_name,Job_id , Salary)

CREATE TABLE EMPLOYEE (

Emp_no INT,

E_name VARCHAR(255),

E_address VARCHAR(255),

E_ph_no VARCHAR(15),

Dept_no INT,

Dept_name VARCHAR(255),

Job_id VARCHAR(10),

Salary DECIMAL(10, 2)

);

1. Add a new column; HIREDATE to the existing relation.

ALTER TABLE EMPLOYEE

ADD HIREDATE DATE;

2. Change the datatype of JOB_ID from char to varchar2.

ALTER TABLE EMPLOYEE

ALTER COLUMN Job_id VARCHAR2(10);

3. Change the name of column/field Emp_no to E_no.

ALTER TABLE EMPLOYEE

RENAME COLUMN Emp_no TO E_no;

4. Modify the column width of the job field of emp tabl

ALTER TABLE EMPLOYEE

ALTER COLUMN Job_id VARCHAR(20);


QUESTION 2)

Write SQL queries for following question:

Create a table EMPLOYEE with following schema:

(Emp_no, E_name, E_address, E_ph_no, Dept_no, Dept_name,Job_id , Salary)

1. Insert aleast 5 rows in the table.

CREATE TABLE EMPLOYEE (

Emp_no INT,

E_name VARCHAR(255),

E_address VARCHAR(255),

E_ph_no VARCHAR(15),

Dept_no VARCHAR(10),

Dept_name VARCHAR(255),

Job_id VARCHAR(10),

Salary DECIMAL(10, 2)

);

2. Display all the information of EMP table.

INSERT INTO EMPLOYEE (Emp_no, E_name, E_address, E_ph_no, Dept_no, Dept_name, Job_id, Salary)

VALUES

(1, 'Shruti','Chandwad', '1234567890', 'D10', 'Mech', 'J001', 50000.00),

(2, 'Akash', 'Shirdi', '9876543210', 'D20', 'Marketing', 'J002', 60000.00),

(3, 'Ankita', 'Pune', '1112223333', 'D10', 'Sales', 'J001', 55000.00),

(4, 'Atharv', 'Nagpur', '4445556666', 'D30', 'HR', 'J003', 70000.00),

(5, 'James', 'Nashik', '7778889999', 'D20', 'Marketing', 'J002', 62000.00);

3. Display the record of each employee who works in department D10.


SELECT * FROM EMPLOYEE WHERE Dept_no = 'D10';

4. Update the city of Emp_no-12 with current city as Nagpur.

UPDATE EMPLOYEE SET E_address = 'Nagpur' WHERE Emp_no = 12;

5. Display the details of Employee who works in department MECH.

SELECT * FROM EMPLOYEE WHERE Dept_name = 'MECH';

6. Delete the email_id of employee James.

UPDATE EMPLOYEE SET E_email = NULL WHERE E_name = 'James';

7. Display the complete record of employees working in SALES Department.

SELECT * FROM EMPLOYEE WHERE Dept_name = 'SALES';

You might also like