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

Step 5: Rename The Column of Employee Table Using Alter Command

The document outlines 6 steps to create and populate an Employee table in a database: 1) create the table, 2) add a commission column, 3) insert 5 records, 4) update an employee's job, 5) rename the manager column, 6) delete an employee record.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Step 5: Rename The Column of Employee Table Using Alter Command

The document outlines 6 steps to create and populate an Employee table in a database: 1) create the table, 2) add a commission column, 3) insert 5 records, 4) update an employee's job, 5) rename the manager column, 6) delete an employee record.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

2.

Step 1: Create the Employee table


CREATE TABLE Employee (
EMPNO INT,
ENAME VARCHAR(15),
JOB VARCHAR(15),
MGR INT,
SAL NUMBER(10, 2) );

Step 2: Add a column commission to the Employee table


ALTER TABLE Employee
ADD COMMISSION NUMBER(10, 2);

3: Insert five records into the Employee table


INSERT INTO Employee (EMPNO, ENAME, JOB, MGR, SAL, COMMISSION) VALUES
(101, 'John Doe', 'Manager', NULL, 5000.00, 1000.00);
INSERT INTO Employee (EMPNO, ENAME, JOB, MGR, SAL, COMMISSION) VALUES
(102, 'Jane Smith', 'Assistant', 101, 3000.00, 500.00);
INSERT INTO Employee (EMPNO, ENAME, JOB, MGR, SAL, COMMISSION) VALUES
(103, 'Michael Johnson', 'Clerk', 101, 2500.00, NULL);
INSERT INTO Employee (EMPNO, ENAME, JOB, MGR, SAL, COMMISSION) VALUES
(104, 'Emily Davis', 'Analyst', 101, 4000.00, 800.00);
INSERT INTO Employee (EMPNO, ENAME, JOB, MGR, SAL, COMMISSION) VALUES
(105, 'David Brown', 'Technician', 103, 2800.00, NULL);

Step 4: Update the column details of job


UPDATE Employee
SET JOB = 'Supervisor'
WHERE EMPNO = 105;

Step 5: Rename the column of Employee table using alter command


ALTER TABLE Employee
RENAME COLUMN MGR TO MANAGER_NO;

Step 6: Delete the employee whose Empno is 105


DELETE FROM Employee
WHERE EMPNO = 105;

You might also like