MY SQL Practise Question
Consider the the following table “Employee”
Write SQL queries for the following:
i) display all records of EMPLOYEE table.
ii) display Emp ID and Name of employees who are from
Dehradun.
iii) Increase salary of all employees by 1000
iv) add new row in the table employee with the following data:
(E0009, ‘Aditya’, ‘IT’, 49800, ‘
[email protected]’, ‘Delhi’)
v) display details of all employees in ascending order of
their salary.
vi) display how many employees are from Delhi
vii) display total salary of all the employees
viii) Identify the most appropriate data type for each ]field with
reason.
ix) Identify the suitable primary key. State the reason for
choosing this ]field for the primary key.
x) Add new column Aadhar No in above table.
Ans::::
Q 2) create a table
-- create
CREATE TABLE EMPLOYEE (
empId INTEGER PRIMARY KEY,
name TEXT NOT NULL,
dept TEXT NOT NULL
);
-- insert
INSERT INTO EMPLOYEE VALUES (0001, 'Clark', 'Sales');
INSERT INTO EMPLOYEE VALUES (0002, 'Dave', 'Accounting');
INSERT INTO EMPLOYEE VALUES (0003, 'Ava', 'Sales');
-- fetch
SELECT * FROM EMPLOYEE WHERE dept = 'Sales';