Worksheets MYSQL 1,2
Worksheets MYSQL 1,2
2. Write MySql command will be used to open an already existing database "LIBRARY".
6. Sharmila wants to make the database named ‘COMPANY’ active. Write MySQL commands for it.
7. Whatis MySQL?
ii.
iii.
11. Write the command to display the name of the active database.
1
My SQL Worksheet-2
(DDL – Table Related commands excluding Alter table)
1. Write an SQL query to create the table 'Menu' with the following structure:
2. Can a table have multiple primary keys? Can it have multiple foreign keys?
3. In a Student table, out of Roll Number, Name, Address which column can be set as Primary key and
why?
4. Ms. Mirana wants to remove the entire content of a table "BACKUP" alongwith its structure to release
the storage space. What MySql statement should she use ?
5. Write MySql command to create the Table STOCK including its Constraints.
Table STOCK :
6. Write one similarity and one difference between CHAR and VARCHAR data types.
7. 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.
8. Roli wants to list the names of all the tables in her database named ‘Gadgets’. Which command (s)
she should use to get the desired result.
2
10. Write one similarity and one difference between UNIQUE and PRIMARY KEY constraints.
11. An attribute A of datatype varchar(20) has the value “Amit” . The attribute B of datatype char(20) has
value ”Karanita” . How many charactersareoccupiedin attributeA?How manycharactersareoccupied in
attributeB?
12. 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.
13. Write SQL query to create a table ‘Player’ with the following structure:
(i) What is the data type of columns OrderId and OrderDate in the table Order ?
(ii) Anita is now trying to insert the following row :
15. Write SQL query to create a table ‘Event’ with the following structure :
Field Type Constraint
EventId Varchar(5) PRIMARYKEY
EventName Varchar(30) NOTNULL
Location Varchar(50)
ClientID Integer
EventDate Date
3
16. 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.
17. “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 :
19. While creating a table named “Employee”, Mr. Rishi got confused as which datatype he should
chose for the column “EName” out of char and varchar. Help him in choosing the right data type to
store employee name. Give valid justification for the same.