wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

MySql commands

Total questions: 136

Worksheet time: 1hrs 9mins

Name
Class
Date
1.

What does SQL stand for?

a)

Structured Query Language

b)

Structured Question Language

c)

Strong Question Language

d)

None of the above

2.

Which of the following can add a row to a table?

a)

Add

b)

Insert

c)

Update

d)

Alter

3.

What does DML stand for?

a)

Data Manipulation Language

b)

Data Modeling Language

c)

Data Markup Language

d)

Data Migration Language

4.

Which of the following is not a keyword of MYSQL?

a)

Select

b)

Top

c)

Group

d)

Insert

5.

Which of the following query is correct to get Current Date from Query?

A. SELECT DATE ( NOW() ) as today;

B. SELECT DATE_FORMAT( NOW( ) , '%Y-%m-%d' ) as today;

a)

A. SELECT DATE ( NOW() ) as today;

b)

B. SELECT DATE_FORMAT( NOW( ) , '%Y-%m-%d' ) as today;

c)

Both A and B

d)

None

6.

Which of the following is not a valid aggregate function?

a)

COUNT

b)

MIN

c)

COMPUTE

d)

MAX

7.

The _________ statement is used to delete a table.

a)

DROP TABLE

b)

DELETE TABLE

c)

DEL TABLE

d)

REMOVE TABLE

8.

Which one of the following sorts rows in SQL?

a)

SORT BY

b)

ALIGN BY

c)

GROUP BY

d)

ORDER BY

9.

The SQL statement that queries or reads data from a table is __________ .

a)

USE

b)

SELECT

c)

READ

d)

QUERY

10.

Which SQL statement is used to return only different values?

a)

SELECT DISTINCT

b)

SELECT UNIQUE

c)

SELECT DIFF

d)

SELECT DIFFERENT

11.

With SQL, how do you select all the columns from a table named "Persons"?

a)

SELECT * FROM Persons

b)

SELECT Persons

c)

SELECT [all] FROM Persons

d)

SELECT *.Persons

12.

In a LIKE clause, you can ask for any 6 letter value by writing

a)

LIKE ______ (that's six underscore characters)

b)

LIKE ...... (that's six dots)

c)

LIKE .{6}

d)

LIKE ??????

13.

Which SQL statement is used to update data in a database?

a)

MODIFY

b)

ALTER

c)

SAVE

d)

UPDATE

14.

SQL can be used to:

a)

Create database structures only.

b)

Query database data only.

c)

Modify database data only.

d)

All of the above can be done by SQL.

15.

The SQL keyword BETWEEN is used:

a)

For ranges.

b)

To limit the columns displayed.

c)

As a wildcard.

d)

None of the above

16.

Which clause is used to “Filters out unwanted data”?

a)

FROM

b)

SELECT

c)

ORDER BY

d)

WHERE

17.

Write a query to display first_name and last_name of all employees who have their first_name starting with 'A'.

a)

Select first_name from employess where first_name LIKE '%A';

b)

Select first_name from employess where first_name LIKE "'A'%";

c)

Select first_name from employess where first_name LIKE 'A%';

d)

Select first_name from employess where first_name LIKE '%A%';

18.

A relational database can have how many types of keys in a table ?

a)

Candidate key

b)

Primary key

c)

Foreign key

d)

All of these

19.

Which one of the following uniquely identifies the tuples/tows in a relation ?

a)

Secondary key

b)

Primary key

c)

Composite key

d)

Foreign key

20.

SELECT is a DDL/DML command ....

a)

DDL

b)

DML

c)

None of these

d)

Both

21.

Which of the following keywords will you use to display unique values of the column dept_name ?


SELECT ______ dept_name from COMPANY;

a)

All

b)

distinct

c)

from

d)

name

22.

Which of the following SQL commands retrieves data from table(s)?

a)

update

b)

select

c)

insert

d)

delete

23.

INSERT INTO EMP VALUES(101,'SUMAN','MANAGER');


Which kind of statement is this ?

a)

DDL

b)

DML

c)

Value

d)

Python statement

24.

What will be the output for :-


SELECT LENGTH("EMPLOYEE");

a)

10

b)

8

c)

EMPLOYEE

d)

1

25.

What will be the output for :-


SELECT ROUND(153.669,2);

a)

153.6

b)

153.7

c)

153.67

d)

153.66

26.

Total number of rows/records/horizontal arrangement in a table is called:

a)

Degree

b)

Records

c)

Integer

d)

Cardinality

27.

Which SQL statement is used to delete an existing row ?

a)

DROP

b)

REMOVE

c)

DELETE

d)

UPDATE

28.

What will be the output for SELECT LENGTH("HELLO")

a)

5

b)

7

c)

HELLO

d)

ERROR

29.

The total number of rows in a table is called as

a)

integer

b)

degree

c)

cardinality

d)

tuples

30.

INSERT INTO EMP VALUES(1221, 'ABC', 'MANAGER',12323); What kind of statement is this ?

a)

DDL

b)

DML

c)

DCL

d)

TCL

31.
Advantages of View are
a)
Security
b)
Query re-usability
c)
Abstraction – hiding data
d)
All
32.
SQL Views are also known as
a)
Complex tables
b)
Simple tables
c)
Virtual tables
d)
Actual Tables
33.

Which SQL command is used to remove rows from the table customer?

a)

Drop from customer ;

b)

Update from customer;

c)

remove from customer ;

d)

Delete from customer where condition ;

34.

Which SQL keyword is used to sort the result-set?

a)

Sort by

b)

order by

c)

sort

d)

none of these

35.

Which of the following must be enclosed in double quotes?

a)

Date

b)

Column alias

c)

String

d)

All of the above

36.

An organized collection of data stored in a central location is known as?

a)

database

b)

flat file

c)

csv

d)

none of these

37.

Which type of database management system represents relations using tables?

a)

Network DBMS

b)

Relational DBMS

c)

Object Oriented DBMS

d)

Hierarchical DBMS

38.

Which of the following scripts will run successfully?

a)

SELECT customer name FROM customers;

b)

SELECT FROM `customers` 'customer name';

c)

SELECT `customer name` FROM customers ORDER BY zone WHERE cat_id = 12;

d)

SELECT `customer name` FROM customers WHERE cat_id = 12 ORDER BY cat_id;

39.

SELECT * FROM sales WHERE amount > 200.

a)

the query will display all the sales records with amounts starting from 200 and above

b)

the query will display all the sales records with amounts less than 200

c)

the query will display all the sales records with amounts greater than 200

d)

the query will output sales records with the amount equal to 200.

40.

Which of the following is not a relational operator?

a)

&&

b)

>=

c)

!=

d)

=

41.

Correct command to create database school

a)

use school ;

b)

make database school ;

c)

create school;

d)

Create database school;

42.

Which operator is used to match column values against a list of values?

a)

between

b)

IN

c)

Like

d)

Is Null

43.

What could be the correct datatype for 'H.NO. 234, SEC-14' data

a)

Date

b)

int

c)

varchar

d)

decimal

44.

Which of the following is not a text function?

a)

TRIM()

b)

TRUNCATE()

c)

LEFT()

d)

MID()

45.

Which of the following is not a numeric function?

a)

MOD

b)

SIGN

c)

MID

d)

POW

46.

Which of the following is not a date function?

a)

Month

b)

Year

c)

Now

d)

Pow

47.

Which of the following functions returns the position of a substring in a given string?

a)

MID

b)

INSTR

c)

SUBSTR

d)

CHAR

48.

What will be printed by the given query?

SELECT LENGTH("WINNER");

a)

7

b)

6

c)

8

d)

9

49.

What will be returned by the given query?

SELECT INSTR("INDIA", "DI");

a)

2

b)

3

c)

-2

d)

-3

50.

What will be returned by the given query?

SELECT concat("It", "was", "ok");

a)

"It was ok"

b)

"Itwasok"

c)

"Itwas ok"

d)

"Tt wasok"

51.

What will be returned by the given query?

SELECT sign(26);

a)

1

b)

-1

c)

0

d)

none

52.

What will be returned by the given query?

SELECT truncate(15.79, -1), truncate(15.79, 0), truncate(15.79, 1);

a)

15 15 15.7

b)

10 15.7 15.9

c)

10 15 15.7

d)

10 10 15.9

53.

What will be returned by the given query?

SELECT month('2020-05-11');

a)

5

b)

11

c)

May

d)

November

54.

The functions that work with one row at a time are called __________________ functions

a)

Multiple Row Functions

b)

Group Functions

c)

Single Row Functions

d)

Aggregate Functions

55.

Full form of API

a)

Application Process Interchange

b)

Application Programs Interchange

c)

Application Process Interface

d)

Application Programming Interface

56.

Connector Library to connect MySQL with Python IDLE is

a)

pymysql

b)

mysql.connector

c)

both a and b

d)

none of these

57.

To display all the databases of MySQL with the help of cursor mycursor , command will be

a)

mycursor.execute("SHOW DATABASES")

b)

mycursor.execute("DESC DATABASES")

c)

mycursor.executes("SHOW DATABASES")

d)

mycursor.execute("SHOW ALL DATABASES")

58.

Correct the error if any

mycursor = mydb.cursor()


mycursor.execute("CREATE TABLE customers (name VARCHAR(25), 'address' VARCHAR(55))")

a)

mycursor.execute('CREATE TABLE customers (name VARCHAR(25), 'address' VARCHAR(55))')

b)

mycursor.execute("CREATE TABLE customers (name VARCHAR(25), address VARCHAR(55))')

c)

mycursor.execute("CREATE TABLE customers (name VARCHAR(25), address VARCHAR(55));")

d)

mycursor.execute("CREATE TABLE customers (name VARCHAR(25), address VARCHAR55))")

59.

After inserting the data we need to issue

a)

rollback

b)

set autocommit

c)

mycur.commit(1)

d)

mycur.commit()

60.

A key which allows unique or null values.

a)

Unique

b)

Null key

c)

Primary key

d)

Alternate key

61.

MySQL suitable datatype to store images is _______.

a)

Boolean

b)

BLOB

c)

LONGTEXT

d)

SET

62.

Which image is associated with MySQL Logo?

a)
b)
c)
d)
63.

What will be printed by the given query?

SELECT LENGTH( " INFORMATICS PRACTICES");

a)

21

b)

22

c)

23

d)

24

64.

Which SQL function is used to find the average value of any column?

a)

Mean()

b)

Avg()

c)

Average()

d)

Sum()

65.

Which function will be used to remove only the trailing spaces from a string?

a)

ltrim()

b)

rtrim()

c)

trim()

d)

all

66.

Which operator performs pattern matching?

a)

Between Operator

b)

Like Operator

c)

Exists Operator

d)

None of these

67.

Which is not a relational database management system?

a)

MySql

b)

IBM DB2

c)

Oracle

d)

Windows

68.

Insert, select, delete and update command are part of _______ language

a)

PHP

b)

SQL

c)

HTML

d)

C++

69.

Which function is used to connect to MySql database?

a)

mysqli_connect()

b)

mysqli_close()

c)

mysqli_query()

d)

$con

70.

_______ helps to execute the SQL query statements in PHP scripting language

a)

mysqli_connect()

b)

mysqli_close()

c)

mysqli_query()

d)

mysqli_connect_error()

71.

What is used to close an existing opened database connection between PHP scripting and MySQL Database Server?

a)

mysqli_connect()

b)

mysqli_close()

c)

mysqli_query()

d)

mysqli_connect_error()

72.

_________ a domain-specific language used in programming and designed for managing data held in a relational database management system

a)

SQL

b)

PHP

c)

HTML

d)

MySql

73.

A _______is a request for data or information from a database table or combination of tables.

a)

query

b)

request

c)

command

d)

instruction

74.

_________is an open-source relational database management system

a)

SQL

b)

PHP

c)

HTML

d)

MYSQL

75.

A ______is an organized collection of data, generally stored and accessed electronically from a computer system.

a)

Table

b)

Database

c)

MYSQL

d)

DBMS

76.

What will be the output of the following query:

Select round(59999.99,-2);

a)

59999

b)

59900

c)

60000

d)

59990

77.

Select the appropriate command to insert rows in a table

a)

INSERT INTO Customers(ID, FirstName, LastName) VALUES ('1', 'User', 'Test');

b)

INSERTINTO Customers(ID, FirstName, LastName) VALUES ('1', 'User', 'Test');

c)

INSERT Between Customers(ID, FirstName, LastName) VALUES ('1', 'User', 'Test');

d)

None of them

78.

____________ command is same as Undo Command

a)

Save

b)

Roll Back

c)

Commit

d)

None of them

79.

Select * from student ;

Above command gives output :

a)

All rows and columns of table student

b)

Selected Rows and columns

c)

All table of Database

d)

Nothing

80.

Write a command to list the name of students with their marks from student table ;

a)

Select * from student

b)

Select all from student

c)

Select Name , Marks from student ;

d)

Select Name , marks with student;

81.

Which of the following function concatenates the first character value to second character value

a)

INSTR()

b)

CHAR()

c)

TRIM()

d)

CONCAT()

82.

Insert the missing statement to get all the columns from the Customers table.

___________________ * from Coustmer.

a)

Insert

b)

select

c)

Update

d)

None of them

83.

What commands should you used in order to scroll through previously entered commands in MySQL?

a)

tab key

b)

arrow keys

c)

up and down arrow keys

d)

num keys

84.

If you are going to use a new database named as studtbl, how do you select it?

a)

SELECT studbl;

b)

USE studtbl;

c)

SELECT DATABASE studtbl;

d)

SELECT * studbl;

85.

What is the command to view ALL available databases?

a)

SHOW ALL;

b)

SELECT DATABASE();

c)

SHOW DATABASE;

d)

SHOW DATABASES;

86.

tells MySQL to go ahead and add the next available number to the id field.

a)

data type

b)

default value

c)

auto_increment

d)

not null

87.

Which clause is used with an "aggregate" function?

a)

GROUP BY

b)

SELECT

c)

WHERE

d)

Both GROUP BY and WHERE

88.

What is the meaning of "GROUP BY" clause?

a)

Group data by column values

b)

Group data by row values

c)

Group data by column and row values

d)

None of the mentioned

89.

How to select number of employees - department wise from Emp table (EmpNo, DeptNo, EmpName)?

a)

Select empno, count(*) from Emp Group By deptno;

b)

Select deptno, count(*) from Emp Group By deptno;

c)

Select empno, count(*) from Emp Order By deptno;

d)

Select deptno, count(*) from Emp Order By deptno;

90.

How to select Maximum Salary of Employee from each Department in Emp table(empno, ename, deptno, sal)?

a)

Select deptno, sal from Emp Group By deptno Order By Max(Sal);

b)

Select deptno, sal from Emp Group By deptno having sal = max(sal);

c)

Select deptno, max(sal) from Emp Group By deptno;

d)

Select deptno, max(sal) from Emp Order By Max(Sal);

91.

Which of the following is correct to count the total salary dept wise where there are more than two employees in a dept from emp table (empno, ename, deptno, sal)

a)

SELECT deptno, sum(sal) As totalsal FROM emp GROUP BY deptno HAVING COUNT(empno) = 2

b)

SELECT deptno, sum(sal) As totalsal FROM emp where COUNT(empno) = 2 GROUP BY deptno

c)

SELECT deptno, sum(sal) As totalsal FROM emp GROUP BY deptno HAVING COUNT(empno) > 2

d)

SELECT deptno, sum(sal) As totalsal FROM emp where COUNT(empno) > 2 GROUP BY deptno

92.

Which clause is used to remove a foreign key constraint?

a)

REMOVE

b)

DELETE

c)

DROP

d)

EXCLUDE

93.

Which keyword is used to specify the foreign key after the table is created?

a)

UPDATE

b)

ALTER TABLE

c)

MODIFY

d)

CHANGE

94.

Which of the following is true about the HAVING clause?

a)

Similar to the WHERE clause but is used for columns rather than groups.

b)

Similar to WHERE clause but is used for rows rather than columns.

c)

Similar to WHERE clause but is used for groups rather than rows.

d)

Acts exactly like a WHERE clause.

95.

The property that enforces foreign key relationships stay intact is called _____________

a)

atomicity

b)

durability

c)

consistency

d)

referential integrity

96.

Which clause names the parent table and the index columns in the table?

a)

REFERENCES

b)

ON DELETE

c)

CONSTRAINT

d)

FOREIGN KEY

97.
What is a candidate key?
a)
Used to uniquely identify a row
b)
Alias for primary key
c)
Used to identify a column
d)
Alias for foreign key
98.
How can we get the number of records or rows in a table?
a)
 Using COUNT
b)
Using NUM
c)
 Using NUMBER
d)
Both a and c above
99.
USE keyword is used to select a ____________________
a)
Table
b)
Column
c)
Database
d)
None of the above
100.
When do we use a HAVING clause?
a)
To limit the output of a query
b)
To limit the output of a query using an aggregate function only
c)
When GROUP by is used
d)
Both a and c above
101.
A relational database  ___________ is a data structure used to store and organize information.
a)
View
b)
Table
c)
Report
d)
Stored Procedure
102.
What is the maximum size of the VARCHAR Column type?
a)
255 char
b)
255 Byte
c)
512 Char
d)
512 Byte
103.
What is the  four pillars of the transactional process ?
A.  Performance  B. Atomicity C. Consistency D.Isolation E.Durability
a)
ABCD
b)
ACDE
c)
BCDE
d)
ABDE
104.
The “father” of MySQL is________.
a)
 Mihael Widenius
b)
Bill Joy
c)
Bill Gates
d)
Stephanie Wall
105.
In a LIKE clause, you can could ask for any value ending in “qpt” by writing
a)
LIKE %qpt
b)
LIKE qpt
c)
LIKE %qpt%
d)
LIKE qpt%
106.
MySQL is
a)
A Programming language
b)
A technique for writing reliable programs
c)
 A Relational Database Management System
d)
None of the Above
107.

The ______ keyword returns all records from the right table (table2), and the matching records (if any) from the left table (table1).

a)

INNER JOIN

b)

RIGHT JOIN

c)

EQUI JOIN

d)

NATURAL JOIN

108.

What is meaning of LIKE '%O%o%' ?

a)

Feature begins with two O's

b)

Feature ends with two o's

c)

Feature has more than two o's

d)

Feature has two O's in it, at any position

109.

A table has 3 columns. student_id, name, department. I need to insert only student_id and name. Which command is true

a)

insert into patient values(101,'Poorva')

b)

insert into patient(student_id,name) values(101,'Poorva')

c)

insert into patient(student_id,name) = (101,'Poorva')

d)

insert into patient values(101,'Poorva','')

110.

Not equal to?

a)

>=

b)

<>

c)

=<

d)

<=

111.

How do we select all rows for the "Designer" table?

a)

SELECT * FROM Designer

b)

SELECT [All] FROM Designer

c)

SELECT Designer.*

d)

SELECT FROM Designer

112.
What is the difference between a left join and a right join?
a)

There is no difference between a left join and a right join.

b)

A left join returns all rows from the left table and matching rows from the right table, while a right join returns all rows from the left table and matching rows from the right table.

c)

A left join returns all rows from the left table and matching rows from the right table, while a right join returns all rows from the right table and matching rows from the left table.

d)

A left join returns only matching rows from the left table and the right table, while a right join returns only matching rows from the right table and the left table.

113.
What is a natural join?
a)
A join that includes only rows that have null values.
b)
A join that matches rows based on their common column names.
c)
A join that includes only rows that have non-null values.
d)
A join that matches rows based on a custom condition.
114.
Which normal form requires that every non-key attribute be fully functionally dependent on the primary key?
a)
First normal form (1NF)
b)
Second normal form (2NF)
c)
Third normal form (3NF)
d)
Fourth normal form (4NF)
115.
What is a subquery?
a)
A query that returns a single row and column.
b)
A query that returns a single row and multiple columns.
c)
A query that returns multiple rows and columns.
d)
A query that is embedded within another query.
116.
Which of the following is an example of a subquery in a SELECT statement?
a)
SELECT COUNT(*) FROM orders;
b)
SELECT * FROM customers WHERE age > 25;
c)
SELECT AVG(price) FROM products WHERE category = 'Electronics';
d)
SELECT * FROM orders WHERE customer_id IN (SELECT id FROM customers WHERE age > 25);
117.
Which normal form eliminates repeating groups by creating a separate table for each group?
a)
First Normal Form (1NF)
b)
Second Normal Form (2NF)
c)
Third Normal Form (3NF)
d)
Fourth Normal Form (4NF)
118.
Which of the following is a valid subquery?
a)
SELECT * FROM customers WHERE age > (SELECT age FROM employees);
b)
SELECT * FROM customers WHERE age = (SELECT name FROM employees);
c)
SELECT * FROM customers WHERE age = (SELECT COUNT(*) FROM employees);
d)
SELECT * FROM customers WHERE age = (SELECT AVG(age) FROM employees);
119.
Which of the following is not a valid subquery operator?
a)
IN
b)
EXISTS
c)
LIKE
d)
ALL
120.
Which of the following is an example of a correlated subquery?
a)
SELECT COUNT(*) FROM customers WHERE age > 25;
b)
SELECT AVG(price) FROM products WHERE category = 'Electronics';
c)
SELECT * FROM employees WHERE department = (SELECT name FROM departments WHERE id = 1);
d)
SELECT * FROM orders WHERE customer_id = (SELECT id FROM customers WHERE name = 'John Doe');
121.
Which normal form eliminates transitive dependencies by creating a separate table for each non-key attribute?
a)
First Normal Form (1NF)
b)
Second Normal Form (2NF)
c)
Third Normal Form (3NF)
d)
Fourth Normal Form (4NF)
122.

What is the result of the following SQL query: SELECT * FROM orders ORDER BY date DESC LIMIT 5;

a)

All orders will be returned in reverse chronological order.

b)

The 5 most recent orders will be returned in chronological order.

c)

The 5 oldest orders will be returned in chronological order.

d)

The 5 most recent orders will be returned in reverse chronological order.

123.

Which of the following SQL queries performs an equi join?

a)

SELECT * FROM customers JOIN orders ON customers.id = orders.customer_id;

b)

SELECT * FROM employees JOIN departments ON employees.department_id = departments.id;

c)

SELECT * FROM products LEFT JOIN categories ON products.category_id = categories.id;

d)

SELECT * FROM sales RIGHT JOIN products ON sales.product_id = products.id;

124.

Which operator is used to select values within a range?

a)

RANGE

b)

BETWEEN

c)

WITHIN

125.

What is the most common type of join?

a)

INNER JOIN

b)

INSIDE JOIN

c)

JOINED

d)

JOINED TABLE

126.

Select mod(20,3)

a)

6

b)

2

c)

3

d)

5

127.

Select round ( 167 . 89)

a)

168

b)

167

c)

167.9

d)

167.88

128.

Select round ( 435. 75 , 1);

a)

435.7

b)

436

c)

435.8

d)

435

129.

Select round ( 854. 34 , 1) ;

a)

854

b)

854. 4

c)

854.3

130.

Select round ( 1654 . 784, 2) ;

a)

1654.79

b)

1654.78

c)

1654.7

d)

1654.8

131.

Select round ( 873 . 873 , 2) ;

a)

873.87

b)

873.88

c)

873

d)

874

132.

Select round(345 . 78 , -1) ;

a)

345.8

b)

300

c)

345

d)

340

133.

Select round ( 764 . 77 , -2 ) ;

a)

760

b)

770

c)

700

d)

800

134.

Select round (823 . 65 , -2) ;

a)

900

b)

800

c)

820

d)

830

135.

Select pow ( 3, 4 )

a)

12

b)

81

c)

16

d)

72

136.

Select pow ( -3 , 2) ;

a)

-9

b)

9

c)

6

d)

-6