Assignment A10.4 of MySQL
Assignment A10.4 of MySQL
4
Database Query Using SQL
Time: 3 Hours MM: 70
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
Q04. Write the command to display the name of the active database
(a) Alter Database
(b) Seek Database
(c) Select Database()
(d) Get Database()
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
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
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");
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);
Q15. What will be the output of the following queries on the basis of Employee Table:
Select Salary+100 from Employee where EmpId='A002';
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
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:
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‟.
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:
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
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;
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”
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)
Q34. Consider the table FLIGHT given below. Write commands in SQL for (i) to (iv) and output
for (v).
Q35. Consider the table „PERSONS‟ given below. Write commands in SQL for (1) to (4) and
write output for (5).