You are on page 1of 46

1.

Write the SQL command to create the table voter including its constraints

Table : BANK

Acc no C Name B name Amount Date of Transactions


open

1 Karan Bank of 15000 1998-01-12 10


Baroda

2 Puneet State Bank 25000 1997-02-01 09

3 Anirudh Oriented 17000 1999-02-10 05


Bank

4 Jatin Standard 38000 1998-02-25 11


Charted

5 Sunny State Bank 47000 1999-01-02 15

a) Create TABLE: BANK


b) Insert values to the table.
c) Display data for all Customers whose transaction is b/w 8 and 11.
d) To count the number of Customers sorted by their date of open.
e) List the minimum and maximum amount from the Bank.
f) To update the amount of all the Customers by 5%.

SOLUTIONS:
a) create table bank(

AccNo integer(1),

Cname varchar(10),

Bname varchar(50),

Amount integer(6),

DateOfOpen date,

T_Transaction integer(2));

b) INSERT into bank values(1,'Karan','Bank of Baroda', 15000,'1998-01-12',10);

INSERT into bank values(2,'Puneet','State Bank',25000,'1997-02-01',09);

INSERT into bank values(3,'Anirudh','Oriented Bank',17000,'1998-02-10',05);

INSERT into bank values(4,'Jatin','Standard Charted',38000,'1998-02-25',11);

INSERT into bank values(5,'Sunny','State Bank',47000,'1999-01-02',15);

c) Select * from bank where T_Transaction between 8 and 11;

d) Select * from bank ORDER BY DateOfOpen;

e) Select MIN(AMOUNT), MAX(AMOUNT) from bank;

f) Update bank

Set Amount = Amount + Amount*5/100;

Output:
2.Write SQL commands on the basis of the Table DIRECTORY.

No. F name L name Phone Address

1 Vikas Kumar 2709653 Rohini

2 Akshay Kapoor 2709876 Vikas puri

3 Aman Garg 2705431 Pritam pura

4 Rohit Sharma 2708965 Preet Vihar

5 Rahul saxena 2709867 Rohini

a) Create table Directory.


b) Insert values in it.
c) To display data for Aman, Rohit and Rahul.
d) To delete the rows where the address is Rohini.
e) To delete the table physically.

SOLUTION:
a)create table directory(

no integer(1),

Fname varchar(8),

Lname varchar(10),

Phone integer(15),

Address varchar(20));

b)

INSERT into directory values(1,'Vikas','Kumar', 2709653,'Rohini');

INSERT into directory values(2,'Akshay','Kapoor',2709876,'Vikas Puri');

INSERT into directory values(3,'Aman','Garg',2705431,'Pritam pura');

INSERT into directory values(4,'Rohit','Sharma',2708965,'Preet Vihar');

INSERT into directory values(5,'Rahul','Saxena',2709867,'Rohini');

b) Select * from directory


Where Fname IN (‘Aman’,’Rohit’,’Rahul’);

c) Delete from directory


Where Address=’Rohini’;

d) Drop table directory;

Output:
3. Write SQL commands on the basis of the Table MAO.
Name Roll NO. Class

1.Aditya 2 12

2.Zameer 3 12

3.Parth 4 12

4.Divyanshu 5 12

a) Create table Mao.


b) Insert values in it.
c) To delete the row where roll no. is 4.
d) To delete the table physically.

Solution:
a) create table mao(name varchar(20),roll_no integer(10));
b) insert into mao values('aditya','2','12');

insert into mao values('zameer','3','12');

insert into mao values('parth','4','12');

insert into mao values('divyanshu','5','12');

c) Delete from mao where roll_no=4;


d) Drop table mao;

Output:
No. Name Age Department DateofAdm Charges Sex
1 Arpita 61 Surgery 1998-01-21 300 F
2 Zareena 26 ENT 1997-12-12 250 F
3 Karim 32 Cardiology 1998-02-11 200 M
4 Arun 12 Surgery 1998-01-11 300 M
5 Zubeen 30 ENT 1998-02-24 250 M
6 Ankita 40 Cardiology 1998-02-20 800 F
7 Shilpa 23 Nuclear 1998-03-21 400 F
Med.
4. Write SQL command from a-e. TABLE: HOSPITAL.

a) Create table HOSPITAL.


b) Insert values to it.
c) To select the all the information of patients of cardiology
department.
d) To list the name of female patient who are in ENT department.
e) To list the names of all patient with their date of admission in
ascending order.

SOLUTION:
a) create table HOSPITAL(
no integer(1),
name varchar(8),
age integer(3),
department varchar(25),
dateofadm date,
charges integer(4),
sex char(1));

b) INSERT into HOSPITAL values(1,’Arpita’,61,’Surgery’,’1998-01-


21’,300,’F’);
INSERT into HOSPITAL values(2,’Zareena’,26,’ENT’,’1997-12-12’,250,’F’);
INSERT into HOSPITAL values(3,’Karim’,32,’Cardiology’,’1998-02-
11’,200,’M’);
INSERT into HOSPITAL values(4,’Arun’,12,’Surgery’,’1998-01-01’,300,’M’);
INSERT into HOSPITAL values(5,’Zubeen’,30,’ENT’,’1998-02-24’,250,’M’);
INSERT into HOSPITAL values(6,’Ankita’,40,’Cardiology’,’1998-02-
20’,800,’F’);
INSERT into HOSPITAL values(7,’Shilpa’,23,’nuclear med.’,’1998-03-
21’,400,’F’);

c) Select * from hospital where department=’cardiology’;

d) Select * from hospital


where department='ENT' AND sex='F';

e) Select name
from hospital
order by dateofadm ;

OUTPUT:
5. Create the following relation bus.

Bus Origin Destination Rate Km Time Type


No.
21 Delhi Bombay 450 32 9:00 AC
22 Delhi Agra 120 82 10:20 NON
23 Bombay Hyderabad 350 72 11:30 AC

24 Delhi Agra 450 52 9:00 AC

Create the database named my trip and do the following:


a) Create the above relation with proper constraint
b) Insert at least 1 record in above relation
c) Write my sql command o do the following:
I. Give all details of bus table.
II. Display data of only those buses where origin is Delhi.
III. Display km, rate and time of those buses whose type is ac.
IV. Give all details of bus no.25.
V. Give rate and km of only those buses where origin is Delhi and
destination is Agra.

SOLUTION:
a) CREATE TABLE BUS
(BUSNO INTEGER (3) PRIMARY KEY,
ORIGIN VARCHAR (3) NOT NULL,
DEST VARCHAR (3) NOT NULL,
RATE INTEGER (3) NOT NULL,
KM INTEGER (3) NOT NULL,
TIME VARCHAR (5),
TYPE VARCHAR (5)
);

b) INSERT INTO BUS VALUES(21,'DEL','BOM', 450, 32,'9:00','AC');


INSERT INTO BUS VALUES(22,'DEL','AGR', 120, 82,'10:20','NON');
INSERT INTO BUS VALUES(23,'BOM','HYD', 350, 72,'11:30','AC');
INSERT INTO BUS VALUES(24,'DEL','AGR', 450, 52,'9:00','AC');

c)
I) SELECT * FROM BUS;

II) SELECT * FROM BUS


WHERE ORIGIN='DEL';

III) SELECT KM,RATE,TIME FROM BUS


WHERE TYPE='AC';

IV) SELECT * FROM BUS


WHERE BUSNO=24;

V) SELECT RATE,KM FROM BUS


WHERE ORIGIN='DEL' AND DEST='AGR';

OUTPUT:
6. Write mysql command to create a table EMPADD with following
specifications:

FIELD DATA LENGTH CONSTRAINT


NAME TYPE
Empid Varchar 5 Primary key
First name Varchar 25 Not null
Last name Varchar 15
Address Varchar 25
City Varchar 15
State Varchar 15
1. Insert
10 different records in empadd table.
2. Write a command to display the employ table.
3. Create another table empsal with following specifications

FIELD NAME DATA TYPE LENGTH CONSTRAINTS


Number Integer 5 Primary key
Salary Float
Benefits Float
Desig. char 15 Not null
4. List the employee id whose salary is more than 5000.
5. List the employee id and salary whose designation is manager.
6. List the employee id and salary whose designation is staff and
salary is more than 5500.
7. List the employee id and salary whose designation is clerk and
salary is more than 15500 or benefit more than 90000.
8. Write a query statement to show all the rows from the empsal
table who does not take any benefit.
9. Write a query to show the designation from empsal table whose
salary is not equal to 15000.
10. List the employee id, salary and benefits by increasing the
salary Rs. 1000 of the previous salary.
11. List the detail of all employees whose benefit is less than
Rs.1000 and more than Rs. 500.

SOLUTION:
1. CREATE TABLE EMPADD
( EMPID INTEGER(5)PRIMARY KEY,
FIRSTNAME VARCHAR(15)NOT NULL,
LASTNAME VARCHAR(15),
ADDRESS VARCHAR(25),
CITY VARCHAR(15),
STATE VARCHAR(15)
);

2. INSERT INTO EMPADD


VALUES(101,'RAMESH','KUMAR','RAJNAGAR','GHAZIABAD','U.P.');
INSERT INTO EMPADD
VALUES(102,'RAJESH','SHARMA','KAVINAGAR','GHAZIABAD','U.P.');
INSERT INTO EMPADD VALUES(103,'ANUJ','MEHTA','KAROLBAGH','NEW
DELHI','DELHI');
INSERT INTO EMPADD
VALUES(104,'NEETA','SAHANI','VIVEKVIHAR','DELHI','DELHI');
INSERT INTO EMPADD
VALUES(105,'AKHILESH','BANNERJEE','KIRTIVIHAR','KOLKATA','WEST BENGAL');
INSERT INTO EMPADD
VALUES(106,'LALITA','KUNDU','PANDITWADI','DEHRADUN','UTTARAKHAND');
INSERT INTO EMPADD
VALUES(107,'KANIKA','MEHRA','RANIPUR','HARIDWAR','UTTARAKHAND');
INSERT INTO EMPADD VALUES(108,'ANEESH','GOEL','DSC
COLONY','JAIPUR','RAJASTHAN');
INSERT INTO EMPADD VALUES(109,'PRATIKSHA','JAIN','DEFENCE
CoLONY','CHENNAI','TAMIL NADU');
INSERT INTO EMPADD VALUES(110,'KARTIK','MISHRA','HAZRAT
GANJ','LUCKNOW','U.P.');

3. DESC EMPADD;

4. CREATE TABLE EMPSAL


( EMPID INTEGER(5) PRIMARY KEY,
SALARY FLOAT,
BENEFITS FLOAT,
DESIG CHAR(15)NOT NULL
);

5. INSERT INTO EMPSAL VALUES


(101,8000,2000,'CLERK');
INSERT INTO EMPSAL VALUES
(102,30000,15000,'MANAGER');
INSERT INTO EMPSAL VALUES
(103,20000,5000,'SALESMAN');
INSERT INTO EMPSAL VALUES
(104,5000,1000,'WORKER');
INSERT INTO EMPSAL VALUES
(105,25000,4000,'SALESMAN');
INSERT INTO EMPSAL VALUES
(106,40000,16000,'ACCOUNTANT');
INSERT INTO EMPSAL VALUES
(107,30000,10000,'MANAGER');
INSERT INTO EMPSAL VALUES
(108,10000,2000,'CLERK');
INSERT INTO EMPSAL VALUES
(109,5000,1200,'WORKER');
INSERT INTO EMPSAL VALUES
(110,35000,12000,'ACCOUNTANT');

6. SELECT EMPID FROM EMPSAL


WHERE SALARY>5000;

7. SELECT EMPID, SALARY FROM EMPSAL


WHERE DESIG='MANAGER';

8. SELECT EMPID, SALARY FROM EMPSAL


WHERE DESIG='STAFF'&& SALARY>5500;

9. SELECT * FROM EMPSAL


WHERE SALARY !=15000;

10. SELECT EMPID, SALARY+1000,BENEFITS FROM EMPSAL;


OUTPUT:
7.
TABLE: STUDENT
FIELD NAME DATA TYPE LENGTH CONSTRAINT
number Integer 5 Primary key
Name Varchar 25 Not null
Fee Integer 5 Not null
Stream Varchar 25 Not null
Avg. marks Float
Grade Char 1
Class varchar 10 Not null

 Create the given table with the given constraints.


 Insert at least 10 tuples in all the relations.
 Describe the structures of the table.
 List the details of all students alphabetically according to stream.
 List the details of the students whose name starts with capital ‘A’.
SOLUTION:-

1) CREATE TABLE STUDENT


( NO INTEGER(5) PRIMARY KEY,
NAME VARCHAR(15) NOT NULL,
FEE INTEGER(5) NOT NULL,
STREAM VARCHAR(15),
AVG FLOAT,
GRADE CHAR(1),
CLASS VARCHAR(10) NOT NULL
);

2) INSERT INTO STUDENT VALUES


(101,'PALKI', 400,'PCM', 100,'A','11 A4'),
(102,'SAMEERA', 400,'PCM',99,'A','11 A4'),
(103,'AISHWARYA' ,400,'PCM',100,'A','11 A4'),
(104,'DIVYA', 400,'PCM', 90,'A','11 A4'),
(105,'NAITIK' ,12000,'COMMERCE',50,'C','11 CS'),
(106,'MANSI', 4000,'PCMB',100,'A','11 A5'),
(107,'RATI' ,5000,'PCM',80,'B','11 A5'),
(108,'DAVID', 14000,'COMP SCIENCE',40,'D','11 A5'),
(109, 'MEENU' ,1400,'PCMB',60,'B','11 CS'),
(110, 'ANKITA' ,15400,'COMMERCE',10,'E','11 CS');

3) SELECT * FROM STUDENT


WHERE FEE IS NULL;
4) SELECT * FROM STUDENT
WHERE FEE IS NOT NULL;
5) SELECT * FROM STUDENT
WHERE NAME LIKE 'A%';
OUTPUT:
8. TABLE : LIBRARY

FIELD NAME DATA TYPE LENGTH CONSTRAINTS


Number Integer 5 Primary key
Title Varchar 25 Not null
Author Varchar 25 Not null
Pub. Varchar 25 Not null
Quatity Integer 4
Price Float
Type Varchar 25
  Create the given table with the given constraints.
 Insert at least 10 tuples in all the relations.
 Describe the structures of all the tables.
 List all the details of those books whose type is fiction and price is
greater than 400 and author name starts with ‘S’.
 List the details of those books whose type is science books and
quantity not more than 10.
 List all the details of those books whose price is more than 500
and author name starts with ‘A’ and publisher name ends with ‘K’.
 List the name of those books whose publisher name starts with ‘A’
and ends with ‘M’ in descending order of publisher name.

SOLUTION:
1) CREATE TABLE LIBRARY
(NO INTEGER (2) PRIMARY KEY,
TITLE VARCHAR (35) NOT NULL,
AUTHOR VARCHAR (50) NOT NULL,
PUBLI VARCHAR (30) NOT NULL,
QUANTITY INTEGER (4) NOT NULL,
PRICE FLOAT NOT NULL,
TYPE VARCHAR (25) NOT NULL
);
2) INSERT INTO LIBRARY VALUES
(1,'TWILIGHT','STEPHENIE MAYOR','HOST',1000 ,250,'ROMANCE'),
(2,'NEW MOON','STEPHENIE MAYOR','HOST',400, 350,'FICTION'),
(3,'3 IDIOTS','ANITA JOYAL','BOOK',300 , 50000,'THRILLER'),
(4,'ALIBABA AND 40 CHOR','PALKI','GHI' ,400, 50,'FICTION'),
(5,'ONE NIGHT AT A CALL CENTER','CHETAN BHAGAT','ANGAD PUBLI',120,
600,'DRAMA'),
(6,'H.C.VERMA','MR.VERMA','GEETA PUBLI', 09 ,120,'SCIENCE'),
(7,'PHYSICS','K.L.GOMBER','PRADEEP PUBLI', 2,500 ,'SCIENCE'),
(8,'INFORMATICS','SUMITA ARORA','ANGAK PUBLI',140, 300,'COMPUTERS'),
(9,'OLYMPIAD','MR. ASHWANI','NGO',15,100,'WORKBOOK'),
(10,'PRELIPKO','MR.SETH','CHAHAT PUBLI',15,400,'MATHEMATICS');
SELECT * FROM LIBRARY
WHERE TYPE='FICTION' && PRICE<400 && AUTHOR LIKE 'S%';
SELECT * FROM LIBRARY
WHERE TYPE='SCIENCE'&& QUANTITY < 10;
SELECT * FROM LIBRARY
WHERE PRICE <500 && AUTHOR LIKE' A%' && PUBLI LIKE '%K';
OUTPUT:
9. TABLE: MOVIE

FIELD NAME DATA TYPE LENGTH CONSTRAINTS


No. Integer 5 Primary key
Title Varchar 25 Not null
Type Varchar 25 Not null
Rating Char 1
star Varchar 30
  Create the given table with the given constraints.
 Insert at least 10 tuples in all the relations.
 Describe the structures of all the tables.
 List all the details of those movies whose rating is ‘A’ and star cast
name starts with ‘S’.
 List all the details of those movies where type is violence or
romance where star name starts with ‘K’.
 List all the details of those movies where rating is ‘B’ or ‘A’ or ‘C’
or ‘D’ and the movie name starts with ‘A’.
 List movie name, type, star cast and price of those print quantity
is less than 10 and star name starts with ‘S’.
 Select different rating from movie table.
 Update the rating of those movies whose star name starts with
‘S’. New rating should be ‘A’.

SOLUTION:
CREATE TABLE MOVIE
(NO INTEGER (5) PRIMARY KEY,
TITLE VARCHAR (35) NOT NULL,
TYPE VARCHAR (35),
RATING CHAR (1),
STAR VARCHAR (40),
QUANTITY INTEGER (4),
PRICE FLOAT );
INSERT INTO MOVIE VALUES
(1,'TWILIGHT','ROMANCE','A','KRISTEN&ROBERT',1000, 250),
(2,'NEW MOON','FICTION','A','KRISTEN&ROBERT' ,400, 350),
(3,'3 IDIOTS','THRILLER','B','FARHAN AKHTAR',300,500),
(4,'KAMINEY','THRILLER','A','SHAHID KAPOOR',400,50),
(5,'ONE NIGHT AT A CALL CENTER','COMEDY','B','KATRINA KAIF',120,600),
(6,'AGYAAT','HORROR','C','KAREENA',09,120),
(7,'HARRY POTTER','MAGIC','A','DANIEL RADCLIFFE',2,500),
(8,'PRIDE AND PREJUDICE','DRAMA','E','SAMEERA',140,300),
(9,'NEW YORK','ROMANCE','A','KATRINA',15,100),
(10,'GHAZINI','VIOLENCE','A','KARISHMA',15,400);
SELECT * FROM MOVIE
WHERE RATING='A'&& STAR LIKE'S%';
SELECT * FROM MOVIE
WHERE TYPE IN('VIOLENCE','ROMANCE')&& STAR LIKE'K%';
SELECT * FROM MOVIE
WHERE RATING IN ('A','B','C','D') && TITLE LIKE 'A%';
SELECT TITLE,STAR ,PRICE FROM MOVIE
WHERE QUANTITY<10 && STAR LIKE 'K%';
SELECT DISTINCT RATING FROM MOVIE ;
UPDATE MOVIE
SET RATING='A'
WHERE STAR LIKE 'S%';
OUTPUT:
10. Write SQL command from a-c.
TABLE: SPORTS

a) Create table Sports.


b) Insert 5 records to the table Sports.

No Name Class Game Grad Game 2 Grade


. 1 eA B
1 Jyoyna 12 Tennis C swimming A
2 Radha 10 Chess A Skating B
3 Adi 8 Cricket B Gymnastics A
4 Daksh 7 Squas A Football B
h
5 Ravi 9 Basket A Tennis A
ball
6 Dimple 11 Tennis C Base ball C
7 Riya 8 Cricket B Chess A
c) Display all the details of students where grade A is A and grade
B is A.
SOLUTION:

a) Create table SPORTS(

name varchar(23),

class integer(2),

game1 varchar(15),

gradeA char(1),

game2 varchar(10),

gradeB char(1));

b) insert into SPORTS values ('JYOYNA',12,'Tennis','C','Swimming','A');

insert into SPORTS values ('RADHA',10,'Chess','A','Skating','B');

insert into SPORTS values ('ADI',8,'Cricket','b','Gymnastics','A');

insert into SPORTS values('DAKSH',7, 'Squash', 'A', 'Foot ball', 'B');

insert into SPORTS values('RAVI',9, 'Basket ball', 'A', 'Tennis', 'A');

insert into SPORTS values('DIMPLE',11, 'Tennis', 'C', 'Chess', 'C');

insert into SPORTS values('RIYA',8, 'Cricket', 'B', 'Base ball', 'A');

c) SELECT * FROM SPORTS

WHERE GRADEA = 'A'&& GRADEB = 'A';


OUTPUT:
SQL PROGRAMS :-

1. Write the SQL command to create the table voter including its
constraints

Table : BANK

Acc no C Name B name Amount Date of Transactions


open

1 Karan Bank of 15000 1998-01-12 10


Baroda

2 Puneet State Bank 25000 1997-02-01 09

3 Anirudh Oriented 17000 1999-02-10 05


Bank

4 Jatin Standard 38000 1998-02-25 11


Charted

5 Sunny State Bank 47000 1999-01-02 15

a) Create TABLE: BANK


b) Insert values to the table.
c) Display data for all Customers whose transaction is b/w 8 and 11.
d) To count the number of Customers sorted by their date of open.
e) List the minimum and maximum amount from the Bank.
f) To update the amount of all the Customers by 5%.
2. Write SQL commands on the basis of the Table DIRECTORY.
No. F name L name Phone Address

1 Vikas Kumar 2709653 Rohini

2 Akshay Kapoor 2709876 Vikas puri

3 Aman Garg 2705431 Pritam pura

4 Rohit Sharma 2708965 Preet Vihar

5 Rahul saxena 2709867 Rohini

a) Create table Directory.


b) Insert values in it.
c) To display data for Aman, Rohit and Rahul.
d) To delete the rows where the address is Rohini.
e) To delete the table physically.

3. TABLE : MAO

Name Roll NO. Class

1.Aditya 2 12

2.Zameer 3 12

3.Parth 4 12

4.Divyanshu 5 12

Write SQL commands on the basis of the Table


a) Create table Mao.
b) Insert values in it.
c) To delete the row where roll no. is 4.
d) To delete the table physically

No. Name Age Department DateofAdm Charges Sex


1 Arpita 61 Surgery 1998-01-21 300 F
2 Zareena 26 ENT 1997-12-12 250 F
3 Karim 32 Cardiology 1998-02-11 200 M
4 Arun 12 Surgery 1998-01-11 300 M
5 Zubeen 30 ENT 1998-02-24 250 M
6 Ankita 40 Cardiology 1998-02-20 800 F
7 Shilpa 23 Nuclear 1998-03-21 400 F
Med.
4. Write SQL command from a-e. TABLE: HOSPITAL.

a) Create table HOSPITAL.


b) Insert values to it.
c) To select the all the information of patients of cardiology
department.
d) To list the name of female patient who are in ENT department.
e) To list the names of all patient with their date of admission in
ascending order.

5. Create the following relation bus.


Bus Origin Destination Rate Km Time Type
No.
21 Delhi Bombay 450 32 9:00 AC
22 Delhi Agra 120 82 10:20 NON
23 Bombay Hyderabad 350 72 11:30 AC

24 Delhi Agra 450 52 9:00 AC

Create the database named my trip and do the following:


a) Create the above relation with proper constraint
b) Insert at least 1 record in above relation
c) Write my sql command o do the following:
I. Give all details of bus table.
II. Display data of only those buses where origin is Delhi.
III. Display km, rate and time of those buses whose type is ac.
IV. Give all details of bus no.25.
V. Give rate and km of only those buses where origin is Delhi and
destination is Agra.

6. Write mysql command to create a table EMPADD with


following specifications:
FIELD DATA LENGTH CONSTRAINT
NAME TYPE
Empid Varchar 5 Primary key
First name Varchar 25 Not null
Last name Varchar 15
Address Varchar 25
City Varchar 15
State Varchar 15
1. Insert
10 different records in empadd table.
2. Write a command to display the employ table.
3. Create another table empsal with following specifications

FIELD NAME DATA TYPE LENGTH CONSTRAINTS


Number Integer 5 Primary key
Salary Float
Benefits Float
Desig. char 15 Not null
4. List the employee id whose salary is more than 5000.
5. List the employee id and salary whose designation is manager.
6. List the employee id and salary whose designation is staff and
salary is more than 5500.
7. List the employee id and salary whose designation is clerk and
salary is more than 15500 or benefit more than 90000.
8. Write a query statement to show all the rows from the empsal
table who does not take any benefit.
9. Write a query to show the designation from empsal table whose
salary is not equal to 15000.
10. List the employee id, salary and benefits by increasing the
salary Rs. 1000 of the previous salary.
11. List the detail of all employees whose benefit is less than
Rs.1000 and more than Rs. 500.

7. TABLE : STUDENT

 Create the given table with the given constraints.


 Insert at least 10 tuples in all the relations.
 Describe the structures of the table.
 List the details of all students alphabetically according to stream.
 List the details of the students whose name starts with capital ‘A’.

FIELD NAME DATA TYPE LENGTH CONSTRAINT


number Integer 5 Primary key
Name Varchar 25 Not null
Fee Integer 5 Not null
Stream Varchar 25 Not null
Avg. marks Float
Grade Char 1
Class varchar 10 Not null
8. TABLE : LIBRARY

 Create the given table with the given constraints.


 Insert at least 10 tuples in all the relations.
 Describe the structures of all the tables.
 List all the details of those books whose type is fiction and price is
greater than 400 and author name starts with ‘S’.

FIELD NAME DATA TYPE LENGTH CONSTRAINTS


Number Integer 5 Primary key
Title Varchar 25 Not null
Author Varchar 25 Not null
Pub. Varchar 25 Not null
Quatity Integer 4
Price Float
Type Varchar 25

 List the details of those books whose type is science books and
quantity not more than 10.
 List all the details of those books whose price is more than 500
and author name starts with ‘A’ and publisher name ends with ‘K’.
 List the name of those books whose publisher name starts with ‘A’
and ends with ‘M’ in descending order of publisher name.
9. TABLE: MOVIE

FIELD NAME DATA TYPE LENGTH CONSTRAINTS


No. Integer 5 Primary key
Title Varchar 25 Not null
Type Varchar 25 Not null
Rating Char 1
star Varchar 30
  Create the given table with the given constraints.
 Insert at least 10 tuples in all the relations.
 Describe the structures of all the tables.
 List all the details of those movies whose rating is ‘A’ and star cast
name starts with ‘S’.
 List all the details of those movies where type is violence or
romance where star name starts with ‘K’.
 List all the details of those movies where rating is ‘B’ or ‘A’ or ‘C’
or ‘D’ and the movie name starts with ‘A’.
 List movie name, type, star cast and price of those print quantity
is less than 10 and star name starts with ‘S’.
 Select different rating from movie table.
 Update the rating of those movies whose star name starts with
‘S’. New rating should be ‘A’.

10. Write SQL command from a-c.


TABLE: SPORTS

a) Create table Sports.


b) Insert 5 records to the table Sports.
c) Display all the details of students where grade A is A and grade
B is A.

No Name Class Game Grad Game 2 Grade


. 1 eA B
1 Jyoyna 12 Tennis C swimming A
2 Radha 10 Chess A Skating B
3 Adi 8 Cricket B Gymnastics A
4 Daksh 7 Squas A Football B
h
5 Ravi 9 Basket A Tennis A
ball
6 Dimple 11 Tennis C Base ball C
7 Riya 8 Cricket B Chess A

You might also like