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

Assignment A10.4 of MySQL

Uploaded by

jiya.kumar2007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Assignment A10.4 of MySQL

Uploaded by

jiya.kumar2007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Assignment A10.

4
Database Query Using SQL
Time: 3 Hours MM: 70

Section A -> (18 x 1=18 Q01 - Q18)

Q01. If a database "Employee" exists, which MySql command helps you to start working in that
database?
(a) Alter Table Employee
(b) Show Employee
(c) Select Employee
(d) Use Employee

Q02. To display the list of the database already existing in MySQL


(a) Select Databases;
(b) Alter Databases
(c) None of these
(d) Show Databases

Q03. To remove the pre-existing database named Clients


(a) Select Database Clients
(b) Alter Database Clients
(c) Drop Database Clients
(d) Delete Database Clients

Q04. Write the command to display the name of the active database
(a) Alter Database
(b) Seek Database
(c) Select Database()
(d) Get Database()

Q05. Write the command to create a new database “School”


(a) Alter new database School
(b) Insert database School
(c) Create Database School
(d) None of these

Q06. Ms. Mirana wants to remove the entire content of a table "BACKUP" along with its
structure to release the storage space. What MySql statement should she use?
(a) DELETE table BACKUP
(b) DROP BACKUP;
(c) Drop table BACKUP
(d) None of these

The Professional / Rajesh Behl # 9911778370 Page 1


Q07. Sahil created a table in Mysql. Later on he found that there should have been another
column in the table. Which command should he use to add another column to the table?
(a) Create table tablename add fieldname datatype(size);
(b) Alter table tablename add fieldname datatype(size);
(c) Insert table tablename add fieldname datatype(size);
(d) None of these

Q08. Rama is not able to change a value in a column to NULL. What constraint did she specify
when she created the table?
(a) Not Null Primary Key
(b) Not Null Unique
(c) Not Null Default
(d) None of these

Q09. Consider the table RESULT given below.

Write command to insert a new row - 6, "Mohan", 500, "English", 73, "Second"
(a) Insert into Result (6, "Mohan", 500, "English", 73, "Second");
(b) Insert into Values Result (6, "Mohan", 500, "English", 73, "Second");
(c) Insert into Result values (6, "Mohan", 500, "English", 73, "Second");
(d) Add into Result (6, "Mohan", 500, "English", 73, "Second");

Q10. What is meant by NULL value in MySQL?


(a) Space Value
(b) Zero Value
(c) Decimal Value
(d) No Value

Q11. Rewrite the following SQL statement after correcting error(s). Underline the corrections
made. INSERT IN STUDENT (RNO, MARKS) VALUE (5,78.5);
(a) INSERT INTO STUDENT VALUES (RNO, MARKS) VALUES (5,78.5);
(b) INSERT INTO STUDENT VALUE (RNO, MARKS) VALUES (5,78.5);
(c) INSERT INTO STUDENT (RNO, MARKS) VALUES (5,78.5);
(d) INSERT INTO STUDENT (5,78.5) VALUES (RNO, MARKS);

Q12. Write the output of the following SQL queries:


a) SELECT ROUND(6.5675, 2);
b) SELECT TRUNCATE(5.3456, 1);

Q13. Write the output of the following SQL queries:


a) SELECT DAYOFMONTH('2009-08-25');
b) SELECT MID('Class 12', 2,3);

The Professional / Rajesh Behl # 9911778370 Page 2


Q14. In a database there are two tables "Product" as shown below :

Write the command to increase the Price of Sanitizer by 20.


(a) Update Product set price=price + 20 where ProductName=”Sanitizer”;
(b) Increase Product price by 20 for ProductName=”Sanitizer”;
(c) Update Product set price=20;
(d) Alter table Product set price = price + 20 where ProductName=”Sanitizer”;

Q15. What will be the output of the following queries on the basis of Employee Table:
Select Salary+100 from Employee where EmpId='A002';

Q16. Write the output of the following SQL queries:


a) SELECT INSTR(„UNICODE‟,‟CO‟);
b) SELECT RIGHT(„Informatics‟,3);

Q17. Write the output of the following SQL queries:


a) SELECT ROUND(563.345,-2);
b) SELECT RIGHT(CONCAT(„PRACTICES‟,‟INFORMATICS‟),5);

Q18. While creating a table named “Employee”, Mr. Rishi got confused as which data type he
should chose for the column “EName” out of char and varchar. Help him in choosing the right
data type to store employee name.
(a) FLOAT
(b) INTEGER
(c) VARCHAR / CHAR
(d) DATE

The Professional / Rajesh Behl # 9911778370 Page 3


Section B -> (7 x 2=14 Q19 – Q25)

Q19. Write an SQL query to create the table 'Menu' with the following structure:

Q20. Write MySql command to create the Table STOCK including its Constraints. Table STOCK:

Q21. Write one similarity and one difference between CHAR and VARCHAR data types.

Q22. Write one similarity and one difference between UNIQUE and PRIMARY KEY constraints

Q23. An attribute A of datatype varchar(20) has the value “Amit” . The attribute B of datatype
char(20) has value ”Karanita” . How many characters are occupied in attribute A ? How many
characters are occupied in attribute B?

Q24. Mrs. Sharma is the classteacher of Class „XII A‟ She wants to create a table „Student‟
to store details of her class.
i) Which of the following can be the attributes of Student table?
a) RollNo b) “Amit” c) Name d) 25
ii) Name the Primary key of the table „Student‟. State reason for choosing it.

Q25. Write SQL query to create a table „Player‟ with the following structure:

The Professional / Rajesh Behl # 9911778370 Page 4


Section C -> (5 x 3=15 Q26 – Q30)

Q26. Answer the following:


a. Can a table have multiple primary keys? Can it have multiple foreign keys?

b. In a Student table, out of Roll Number, Name, Address which column can be set as
Primary key and why?

c. Saumya had previously created a table named „Product‟ in a database using MySQL.
Later on she forgot the table structure. Suggest her suitable MySQL command through
which she can check the structure of the already created table.

Q27.
a. Anita has created the following table with the name „Order‟.

One of the rows inserted is as follows:

1. What is the data type of columns OrderId and OrderDate in the table Order?
2. Anita is now trying to insert the following row:

Will she be able to successfully insert it? Give reason.

b. Write SQL query to create a table „Event‟ with the following structure :
Field Type Constraint
EventId Varchar(5) PRIMARY KEY
EventName Varchar(30) NOT NULL
Location Varchar(50)
ClientID Integer
EventDate Date

The Professional / Rajesh Behl # 9911778370 Page 5


Q28.
a. Observe the given table carefully and answer the following questions:

i. Name the column that might have a Primary Key constraint. Justify your answer.
ii. Name the column that might have a Unique constraint. Justify your answer

b. “ABC” Event Management Company requires data of events that are to be organized.
Write SQL query to create a table „Event‟ with the following structure:

Q29.
a. While creating a table 'Customer' Simrita forgot to set the primary key for the table. Give
the statement which she should write now to set the column 'CustiD' as the primary key
of the table?
b. Write SQL command to remove column named „Hobbies‟ from a table named „Student‟.
c. Rashi wants to add another column „Hobbies‟ with data type and size as VARCHAR(50)
in the already existing table „Student‟. She has written the following statement. However
it has errors. Rewrite the correct statement.
MODIFY TABLE Student Hobbies VARCHAR;

Q30. Consider the following table named “GARMENT”.

1) Write command To change the colour of garment with code as 116 to “Orange”.
2) Write command to increase the price of all XL garments by 10%
3) Write command to delete the record with GCode “116”

The Professional / Rajesh Behl # 9911778370 Page 6


Section D -> (2 x 4=8 Q31 – Q32)

Q31. Answer the following:


a) Pooja, a students of class XI, created a table "Book". Price is a column of this table. To
find the details of books whose prices have not been entered she wrote the following
query: Select * from Book where Price = NULL;
b) The LastName column of a table "Directory" is given below:
Based on this information, find the output of the following queries:
a) SELECT lastname FROM Directory WHERE lastname like "_a%";
b) SELECT lastname FROM Directory WHERE lastname not like
"%a";

c) When using the LIKE clause, which wildcard symbol represents any sequence of none,
one or more characters?
d) In MySQL, Sumit and Fauzia are getting the following outputs of ItemCodes for
SELECT statements used by them on a table named ITEM.(Both have used the SELECT
statements on the same table ITEM).
Fauzia‟s Output
Sumit‟s Output 101
101 102
102 105
101 107
105
101
107

Which extra keyword has Fauzia used with SELECT statement to get the above output?

Q32. Consider the table TEACHER given below. Write commands in SQL for (1) to (3) and
output for (4)

i. To display all information about teachers of PGT category.


ii. To list the names of female teachers of Hindi department.
iii. To list names, departments and date of hiring of all the teachers in ascending order of date of
joining
iv. SELECT DISTINCT(category) FROM teacher;

The Professional / Rajesh Behl # 9911778370 Page 7


Section E -> (3 x 5=15 Q33 – Q35)

Q33. Consider the following table:


Write commands in SQL for (i) to (iv) and
output for (v):
i. To display the details of all those
students who have IP as their optional subject.
ii. To display name, stream and optional
of all those students whose name starts with
„A‟.
iii. To give an increase of 3 in the average
of all those students of humanities section
who have Maths as their optional subject.
iv. To display a name list of all those
students who have average more than 75.
v. Select name from students where optional IN („CS‟,‟IP‟);

Q34. Consider the table FLIGHT given below. Write commands in SQL for (i) to (iv) and output
for (v).

(i) Display details of all flights starting from Delhi.


(ii) Display details of flights that have more than 4 number of flights operating.
(iii) Display flight codes, starting place, destination, number of flights in descending order of
number of flights.
(iv) Display destinations along with flight codes of all the destinations starting with „A‟.
(v) SELECT DISTINCT(NO_STOPS) FROM FLIGHT;

Q35. Consider the table „PERSONS‟ given below. Write commands in SQL for (1) to (4) and
write output for (5).

The Professional / Rajesh Behl # 9911778370 Page 8


1. Display the SurNames, FirstNames and Cities of people residing in Udhamwara city.
2. Display the Person Ids (PID), cities and Pincodes of persons in descending order of
Pincodes.
3. Display the First Names and cities of all the females getting Basic salaries above 40000.
4. Display First Names and Basic Salaries of all the persons whose firstnames starts with
“G”.
5. SELECT Surname FROM Persons Where BasicSalary>=50000;

The Professional / Rajesh Behl # 9911778370 Page 9

You might also like