Write SQL statements for Employee Table (Emp_Id, Name, Address, Salary)

Following table is provided to you:

Employee

Emp_Id Name Address Salary
1 Anil Parajuli Chabahil 50000
2 Gokul Pandey Pokhara 60000
3 Krishna Bdr Oli Chabahil 70000
4 Sumedha Prajapati Bhaktapur 80000
5 Pravin Shrestha Lazimpat 90000
6 Alka Maharjan Lalitpur 100000

 

Write SQL statements for the above table.

i. To create above table named Employee.

ii. To insert all the values in the table.

iii. To increase the salary of Pravin by 15%.

iv. To change the name of Alka to Mamata.

v. To delete the record of Anil.

i. To create above table named Employee.


 CREATE TABLE Employee
  (
     Emp_Id  INT NOT NULL auto_increment PRIMARY KEY,
     Name    VARCHAR(50) NOT NULL,
     Address VARCHAR(50),
     Salary  INT
  );  

 

ii. To insert all the values in the table.

 INSERT INTO Employee
            (Name,
             Address,
             Salary)
VALUES      ('Anil Parajuli',
             'Chabahil',
             50000),
            ('Gokul Pandey',
             'Pokhara',
             60000),
            ('Krishna Bdr Oli',
             'Chabahil',
             70000),
            ('Sumedha Prajapati',
             'Bhaktapur',
             80000),
            ('Pravin Shrestha',
             'Lazimpat',
             90000),
            ('Alka Maharjan',
             'Lalitpur',
             100000);  

 

iii. To increase the salary of Pravin by 15%.


UPDATE Employee
SET    Salary = Salary + Salary * 0.15
WHERE  Emp_Id = 5;  

 

iv. To change the name of Alka to Mamata.


UPDATE Employee
SET    Name = 'Mamata Maharjan'
WHERE  Emp_Id = 6;  

 

v. To delete the record of Anil.


DELETE FROM Employee
WHERE  Emp_Id = 1;