Mysql Assignment Cs - Class 12 Second Term Exerecise 1: Table: Member
Mysql Assignment Cs - Class 12 Second Term Exerecise 1: Table: Member
1. Create the table Member with Primary key constraint to TNO and NOT NULL constraint to
TNAME, SALARY, AREA, AGE, GRADE, and DEPT. Decide your own suitable data types.
2. Show the structure of the table.
3. Insert records in a table Member.
Insert into member values( , , , , , , , , )
8. Add one more column SNO as integer data type as first field.
9. Add one more column BONUS as integer data type at the end.
10. Modify the data type of TNAME as VARCHAR(30).
Alter table member modify Tname varchar(30)
11. Drop the primary key constraint.
12. Add a primary key constraint to TNAME.
ALTER TABLE Members
ADD PRIMARY KEY (TNAME);
1. Create the table Empl with Primary key constraint to EMPNO and NOT NULL constraint to
ENAME, JOB, HIREDATE, SAL and DEPTNO.
2. Insert records in a table Empl.
3. Display all the records from table Empl.
4. Display EMPNO and ENAME of all employees from table Empl.
5. Display ENAME, SAL and SAL added with COMM from table Empl.
6. Write a query to display employee name, salary and department number who are not getting
commission from table Empl.
11. List the details of all employees whose name starts with ‘M’.
Select * from employees where name like ”m%”;
12. List the details of all employees whose name ends with ‘A’.
Select * from empl where ename like “%a”;
Like “_a%” “ %a%
13. List name of all employees whose commission is not null.
Select ename from empl where comm is not null;
14. List the details of all employees who are either CLERK or SALESMAN.
15. List all records in ascending order of department number.
Exercise : 4 – 1. Define and Identify the Primary key and Candidate key(s) in the following table
Dept.
Deptno DeptName Location
1 Physics First Floor
0
1
0 English Second
2 Floor
3
1 Chemistry Second
0 Floor
3
1 Computer Third Floor
0
4
1 Maths Third Floor
0
5
2. Vibha has created a table Sales in MySQL.
Salesman_ Com
No m
1001 200
1002 800
1003 NUL
L
1004 800
1005 NUL
L
3. A table “Student” has 10 rows and each row has 6 columns. What is the degree and
cardinality of the table?
4. The column Ename of the table “Employee” is given below:
Arpit
Zarina
Kareem
Aruna
Ankit
What will be the output of the following queries:
i. SELECT Ename FROM Employee WHERE Ename like “%a”;
ii. SELECT Ename FROM Employee WHERE Ename like “_r%”;