MYSQLAssignments Solutions
MYSQLAssignments Solutions
Q1 Write the output of the following on the basis of given table: Product
Ans
(a) 320
(b) 218
(c) 17
(d) 5
(e) 5
(f) 240
300
320
130
100
(g) 5
(h) 5520
7200
13760
4160
1700
(i) 1090
(j) Error
Q2
(a) what is the degree and cardinality of table who has 10 columns and 10 rows?
Ans degree -6 and cardinality-10
(b) identify the errors in the following query
(i) select * from student where name=NULL;
Ans select * from student where name is NULL;
Ans drop command delete the data as well as structure of table permanently from database while
delete command delete only the data from the table.
Ans alter command is used to change the structure of table and update command is used to modify the
data of table.
Ans This clause is used to arrange same data in groups using some functions like sum, average etc
Name,admno,subject,average,position
Ans A function which work on multiple values and return a single value.
Ans order by
Ans count()
Ans different output shows that there must be one null value in a column fee.
Q12 _____________function returns the average value of a numeric column. Ans avg()
Ans sum()
Q15 Write a query to display all the records of table student whose name starts from “A”
Q16 Which function return the minimum value from column fee of table student?
Ans min()
#-----------------------------------------------------------------------------------------------------------
Solution of Assignment 4
Q1 Write the output of the following:
Ans 79
Table : student
Ans
#---------------------------------------------------------------------------------------------------------
Solution of Assignment 5
Ans Delete
Ans Alter
Q3 Write a query to add the column DOB of data type date in the table student.
Q4 Write a query to add new column “Grade” of data type varchar(2) in table “student” with default
value “A”
Q5 Write a query to change the data type of above added column(Grade) to varchar(4).
The above command will delete all the records from table “emp”.(True/False)
Ans True
Q10 Write a query to display all the records from table “Student”
#---------------------------------------------------------------------------------------------------------------------------
Solution of Assignment 6
Ans drop
Q2 which command is used to show the structure of the table.
Q3 Name the columns which are visible when we execute the following command desc book;
Sname Varchar(30)
Ans
Create tale student(Rollno integer(5) not null primary key, Sname varchar(30), Contactno char(10) not
null);
Ans No
Ans Null means a value which is unavailable or in other words we can say Null means no value.
Ans update
Q10 Write a query to modify the Contactno to 98789878 whose roll number is 1 in table student.(gicen
above)
#-----------------------------------------------------------------------------------------------------------------------------
Solution of Assignment 7
Q1
Ans semicolon(;)
Ans False
#---------------------------------------------------------------------------------------------------------------
Solution of Assignment 8
Ans True
Ans yyyy/mm/dd
Q3 Data type of “name” field in a table is char(25). How many bytes will be occupied by values “Ram”
and “Ramesh Kumar”?
Ans 25
Ans hh:mm:ss
Ans False
Ans quit
Ans Boolean
Q8 Out of char,varchar and memo, which data type is used to store large amount of data?
Ans memo
Q10 Write the appropriate data types for the following fields.
(a) Dateofbirth
(b) Salary
(c) Name
(d) Address
(e) Phonenumber
Ans
(a) Date
(b) Any numeric data type preferable numeric or decimal
(c) Char or varchar
(d) Char or varchar
(e) Char or numeric
#--------------------------------------------------------------------------------------------------------------
Solution of Assignment 9
Ans
Ans 1. DDL
2.DML
Ans
DDL DML
Data definition language Data manipulation language
These are used to perform tasks related to the These commands are used to manipulate data
structure of the table
(a) Create
(b) Alter
(c) Insert
(d) Update
(e) Drop
(f) Delete
(g) Select
(h) Grant
(i) Revoke
Ans
(a) DDL
(b) DDL
(c) DML
(d) DML
(e) DDL
(f) DML
(g) DML
(h) DDL
(i) DDL
Ans Data type refers to the type of data we are entering in the column of the table.
Q9 Which data type is used for ‘Date of birth’ field in student table.
Ans Date
Ans char is fixed length data type while varchar is variable length data type.
#------------------------------------------------------------------------------------------------------------
Solution of Assignment 10
Ans table
Ans
Ans True
Ans