0% found this document useful (0 votes)
3 views

lab_program2

The document outlines SQL commands to create and manipulate an Employee table in a database named CMPNY. It includes steps to add a commission column, insert five employee records, update a job title, rename a column, and delete an employee with a specific EMPNO. The commands demonstrate basic database operations such as creating tables, altering structures, and performing CRUD operations.

Uploaded by

gayathri
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

lab_program2

The document outlines SQL commands to create and manipulate an Employee table in a database named CMPNY. It includes steps to add a commission column, insert five employee records, update a job title, rename a column, and delete an employee with a specific EMPNO. The commands demonstrate basic database operations such as creating tables, altering structures, and performing CRUD operations.

Uploaded by

gayathri
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

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 Employee table.


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.

CREATE DATABASE CMPNY;


USE CMPNY;
CREATE TABLE Employee (
EMPNO INT,
ENAME VARCHAR(50),
JOB VARCHAR(50),
MGR INT,
SAL DECIMAL(10, 2));
SHOW TABLES;

ALTER TABLE Employee


ADD COLUMN COMMISSION DECIMAL(10, 2);

DESC Employee;

INSERT INTO Employee VALUES( 101, 'Geeta', 'Manager', NULL,45000.00,1000.00);


INSERT INTO Employee VALUES(102, 'Krishna', 'Developer',101,80000.00, NULL );
INSERT INTO Employee VALUES(103,'Abdul', 'Sales person',102,30000.00,500.00);
INSERT INTO Employee VALUES(104,'Rita','Accountant', 101,45000.00, NULL );
INSERT INTO Employee VALUES(105, 'Amart','HR Manager',101,58000.00,800.00 );

SELECT * FROM Employee;

UPDATE Employee
SET JOB = 'Senior Developer'
WHERE EMPNO = 102;

SELECT * FROM Employee;

ALTER TABLE Employee CHANGE COLUMN MGR MANAGER_ID INT;


DESC Employee;

DELETE FROM Employee


WHERE EMPNO = 105;

SELECT * FROM Employee;

You might also like