MYSQL PRACTICE QUESTION PAPERS
MYSQL PRACTICE QUESTION PAPERS
Ans.
1. A field which uniquely identifies each and every record in table is called primary key.
2. A FOREIGN KEY is a field (or collection of fields) in one table that refers to the PRIMARY KEY in
another table. It is used to link two tables.
3. Those fields which can act as a primary key are called candidates key.
4. Those fields which are candidate keys but not selected as primary key.
Q3. A group of rows and columns is called _______________
Ans Table
Q4. Candidate Key – Primary key = ___________________
Ans. Raw facts and figures is called Data. Processed data is called information
Q7. A primary key is one of the candidate key. (True/False)
Show Answer
Q8. What do you mean by degree and cardinality in DBMS?
Ans. Number of rows in a table is called cardinality. Number of columns in a table is called degree.
Q9. What is the alternate name of column in table?
Ans.
1. Hierarchical Data Model
2. Network Data Model
3. Relational Data Model
Q15. A ___________ is a collection of logically related data.
Ans. table
Q16. Answer the following questions on the basis the given table.
Admno Name Subject Sex Average
Ans. degree – 5
d. What is the cardinality of above table?
Ans. Cardinality – 2
e. Name the primary key in the table.
Ans. Book number (book_no), Book name(bname) , Book Author(b_author), subject, book price(b_price)
Q18. Write any two advantages of database.
Ans. Primary key is created in table to search a particular record in tables as uniqueness helps to search
record.
Q20. Which field you choose as primary key out of following in “Employee” table
1. Emp_id
2. Emp_name
3. Emp_salary
4. Emp_desig
Ans. Emp_id
Ans.
It is very easy to learn
It is not a case sensitive language.
Q22. MySQL is an ___________Software. (open source/Proprietary)
Ans.
DDL DML
It stands for Data Definition Language It stands for Data Definition Language
Ans
1. DDL
2. DDL
3. DML
4. DML
5. DDL
6. DML
7. DML
Q26. What do you mean by data type?
Ans. Data type refers to the type of data we are entering in the column of the table.
Q27. Name two numeric data type in MySQL.
Ans. Date
Q30. What is the difference between Char and Varchar.
Ans. Char is fixed length data type while Varchar is variable length data type.
SQL Practice Questions
SQL Practice Questions – Test 4
Q31. In MySQL, date values to be enclosed in { } or in single quotation marks(True/False)
Ans. True
Q32. ______________ is the format of date in MySQL.
Ans. yyyy/mm/dd
Q33. Data type of “name” field in a table is char(25). How many bytes will be occupied by values “Ram”
and “Rohan Kumar”?
Ans. 25
Q34. Time data type is used to store time in ________ format.
Ans. hh:mm:ss
Q35. Varchar is a fixed length data type.(True/False)
Ans. False
Q36. Name the command which is used to close MySQL.
Ans. quit
Q37. Which data type in MySQL is used to store logical values?
Ans. Boolean
Q38. Out of char, varchar and memo, which data type is used to store large amount of data?
Ans. memo
Q39. Which data type in MySQL is used to store images, animations, clips etc.
Ans.
1. Date
2. Any numeric data type preferable numeric or decimal.
3. Char or Varchar
4. Char or Varchar
5. Char or Numeric
SQL Practice Questions
SQL Practice Questions – Test 5
Q41. What do you mean by keyword in MySQL?
Ans. Semicolon(;)
Q44. We can create ____________ (database/tables)inside ___________(database/tables).
Ans. False
Q46. _________ statement is used to show all the existing databases in server.
Ans. Drop
Q52. Which command is used to show the structure of the table.
Ans. Create table student(Rollno integer(5) not null primary key, Sname varchar(30), Contactno char(10)
not null);
Q55. Write query to insert the following record in above created table.
Roll number — 1, Name–Amit, Contact number– 1234567890
Ans. No
Q58. What do you mean by Null in MySQL?
Ans. Null means a value which is unavailable or in other words we can say Null means no value.
Q59. Which command is used to modify data in table?
Ans. Update
Q60. Write a query to modify the Contactno to 98789878 whose roll number is 1 in table student.(given
above)
Ans. Delete
Q62. Which command is used to add column in a table?
Ans. Alter
Q63. Write a query to add the column DOB of data type date in table Student.
Ans. True
Q70. Write a query to display all the records from table “Student”
Ans. 79
Q . Write the queries of the following:
Table : Student
Table : Student
Ans. A function which work on multiple values and return a single value.
Q82. Which keyword is used to arrange records in increasing or decreasing order?
Ans. Order by
Q83. Which function returns the total number of records in a table?
Ans. Count( )
Q84. Select count( * ) from student; return 5 and Select count(fee) from student; return 4
why different output is coming in above two queries?
Ans. Different output shows that there must be one null value in column fee.
Q85. ____________ function return the average value of a numeric column.
Ans. avg( )
Q86. Which function returns the sum of numeric column?
Ans. sum( )
Q87. _______ keywords removes duplicates records from the table.
Ans. distinct
Q88. Write a query to display all the records of table student whose name starts from “A”
Ans. min( )
SQL Practice Questions
SQL Practice Questions – Test 10
Q91. What is the difference between drop and delete command?
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.
Q92. Differentiate between Alter and Update command.
Ans. Alter command is used to change the structure of table and Update command is used to modify the
data of table.
Q93. What is group by clause?
Ans. This clause is used to arrange same data in groups using some group functions like Sum, average etc.
Write the output of the following:
Q94. Select 75 + 3*2
Ans. 81
Q95. Select 23 + 56%5
Ans. 24
Q96. Select power(2,3)
Ans. 8
Q97 Select round(10.237,2)
Ans. 10.24
Q98 Select round(12.3454,2)
Ans. 12.35
Q99.Select round(12.3444,2)
Ans. 12.34
Q100. Write the query on the basis of the following table : STUDENT
Name, Admno, Subject, Average, Position
a. Display all records in ascending order by name
Ans. Select * from student where position =”First” and Average >70;
SQL Practice Questions
SQL Practice Questions – Test 11
Identify the errors in the following query
Q101 Select * from Student where Name = NULL;
Ans. Select max(salary) from employee group by designation having DOJ > “2020-02-02”;
Q103 Select * from student where name is = “Amit”;
Ans. Select * from employee where salary between 1000 and 2000;
Q105. Select * from employee where name = “A%”;
Ans. Select Name , Subject from student where average >20 and average < 30;
Q107. Select * from Student where Name = “Amit” and Name =”Sumit”;
Ans. 320
Q112. Select avg(price) from product;
Ans. 218
Q113. Select min(qty) from product;
Ans. 17
Q114. Select count(*) from product;
Ans. 5
Q115. Select count(Qty) from product;
Ans. 5
Q116. Select distinct(price) from product;
Ans.
240
300
320
130
100
Q117. Select count(distinct(price)) from product;
Ans. 5
Q118. Select price * Qty from product;
Ans.
5520
7200
13760
4160
1700
Q119. Select sum(price) from product;
Ans. 1090
Q120. Select sum(price) where Qty > 30;
Ans. Error
SQL Practice Questions – Test 13
Q121. Write the queries of the following on the basis of given table : Faculty
Ans. Select * from faculty where Fsal > 25000 and Fname like “%n”;
6. Count number of faculties whose name starts with ‘S’ and salary more than 40000.
Ans. Select count(*) from faculty where Fname like “S%” and Fsal > 40000;
7. Display all records in increasing order of name.