0% found this document useful (0 votes)
67 views1 page

Lab 2 Create A Table Called Employe

Uploaded by

cambrige47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views1 page

Lab 2 Create A Table Called Employe

Uploaded by

cambrige47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Lab 2: Create a table called Employee that contain attributes EMPNO,ENAME,JOB,

MGR,SAL &
execute the following.
1. Add a column commission with domain to the Employeetable.
2. Insert any five records into the table.
3. Update the column details of job
4. Rename the column of Employ table using alter command.
5. Delete the employee whose Empno is 105.

************SQL Commands ********************

-- Step 1: Create the Employee Table


CREATE TABLE Employee (
EMPNO NUMBER,
ENAME VARCHAR2(50),
JOB VARCHAR2(50),
MGR NUMBER,
SAL NUMBER
);

-- Step 1: Add a column commission with domain


ALTER TABLE Employee
ADD COMMISSION NUMBER;

-- Step 2: Insert five records into the table


INSERT INTO Employee (EMPNO, ENAME, JOB, MGR, SAL, COMMISSION) VALUES (101,
'Alice', 'Manager', 1001, 60000, 5000);
INSERT INTO Employee (EMPNO, ENAME, JOB, MGR, SAL, COMMISSION) VALUES (102, 'Bob',
'Developer', 1002, 55000, 3000);
INSERT INTO Employee (EMPNO, ENAME, JOB, MGR, SAL, COMMISSION) VALUES (103,
'Charlie', 'Analyst', 1003, 50000, 2000);
INSERT INTO Employee (EMPNO, ENAME, JOB, MGR, SAL, COMMISSION) VALUES (104,
'David', 'Clerk', 1004, 40000, 1000);
INSERT INTO Employee (EMPNO, ENAME, JOB, MGR, SAL, COMMISSION) VALUES (105, 'Eve',
'Sales', 1005, 45000, 1500);

-- Step 3: Update the column details of job


UPDATE Employee
SET JOB = 'Senior Developer'
WHERE ENAME = 'Bob';

-- Step 4: Rename the column commission to bonus


ALTER TABLE Employee
RENAME COLUMN COMMISSION TO BONUS;

-- Step 5: Delete the employee whose Empno is 105


DELETE FROM Employee
WHERE EMPNO = 105;

-- Verify the final state of the table


SELECT * FROM Employee;

You might also like