MySQL Solution 1st 5 Worksheets
MySQL Solution 1st 5 Worksheets
2 Use Library.
6 Use Company.
10 i. Show Databases.
ii. Use City.
iii. Drop database clients.
3 Roll Number can be set as Primary Key as two students cannot have a same roll number.
Difference:
Char is a fixed length character datatype whereas varchar is a variable length character
datatype.
7 Describe Product.
8 Use Gadgets.
Show tables.
9 i) Drop table name.
ii) Describe table name.
10 Similarity:
Both Unique and primary key restricts duplicate values in the field.
Difference:
Unique allows null values whereas Primary does not allow null values to be inserted in the
field.
11 A will occupy 4-character space.
B will occupy 20-character space.
12 i) Roll No and Name can be the attributes of student table.
ii) Roll No can become the primary key of the student table as two students cannot
have a same roll number.
13 Create table Player (
Player id integer primary key,
Name varchar (50),
Height integer,
Weight integer,
Date birth date,
Team name varchar (50)).
14 i)The datatype for order ID field can be either char or varchar
The datatype for order Date is date
ii) She will not be able to insert the above record as she is inserting a null value in the
order date field and the order date field have a not null constraint which cannot accept
null values.
15 Create table Event (
Event ID varchar (5) Primary Key,
Event Name varchar (30) not null,
Location varchar (50),
Client ID Integer,
Event Date
16 i. Pan No might have a Primary Key constraint as two persons cannot have a same
Pan Number.
ii. Phone No might have a unique constraint as two persons will be having different
mobile numbers.
17 Create table Event (
Event ID Integer Primary Key,
Event Varchar (5 0),
Date Event Date,
Num Performers Integer)
18 i. Show databases.
ii. Use City.
iii. Drop database Clients.
iv. Drop table Club.
19 EName field can have a varchar as a datatype as two employees will not be having a same
length of their names.
My SQL Worksheet-3
(DDL – Table Related commands)
1 Alter table name add fieldname datatype(size).
2 Insert into Result values (6, "Mohan", 500, "English", 73, "Second").
3 Insert into Result values ('110', 'Pizza’, 'Papa Jones', 120, "Kolkata", 50.0).
3 Update Employee set Last name=” Singh” where last name=” Sharma”;
5 Update Gym set brand name=” Fit Trend India” where I code=” G101”.