wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

MYSQL - FIN

Total questions: 90

Worksheet time: 2hrs 3mins

Name
Class
Date
1.

What is the purpose of the ORDER BY clause in MySQL?

a)

To insert new records

b)

To sort the result set in ascending or descending order

c)

To delete records

d)

To update existing records

2.

Which keyword is used with ORDER BY to sort in descending order?

a)

ASC

b)

DESC

c)

SORT

d)

DOWN

3.

What will happen if you use ORDER BY without specifying ASC or DESC?

a)

It will throw an error

b)

It will sort in ascending order by default

c)

It will sort in descending order by default

d)

It will sort randomly

4.

Which of the following is a valid ORDER BY clause?

a)

ORDER BY column1, column2 DESC

b)

ORDER BY 1, 2

c)

Both a and b

d)

Neither a nor b

5.

The INSERT INTO statement is used to:

a)

Sort data

b)

Add new records to a table

c)

Delete records

d)

Update records

6.

Which syntax is correct for inserting a single row?

a)

INSERT INTO table_name (column1, column2) VALUES (value1, value2)

b)

INSERT table_name VALUES (value1, value2)

c)

Both a and b

d)

Neither a nor b

7.

What happens if you omit column names in an INSERT INTO statement?
NOTE: omitting column names means you don’t specify the columns into which you’re inserting data.

a)

It inserts values into all columns in the order they are defined

b)

It throws an error

c)

It inserts null values

d)

It sorts the data

8.

Which clause can be combined with INSERT INTO to sort the inserted data?

a)

ORDER BY

b)

WHERE

c)

GROUP BY

d)

None of the above

9.

In ORDER BY, what does sorting by a column number (e.g., ORDER BY 2) refer to?

a)

The second row

b)

The second column in the SELECT list

c)

The second table

d)

The second database

10.

Which of the following is a valid INSERT INTO statement?

a)

INSERT INTO users (id, name) VALUES (1, 'John')

b)

INSERT INTO users VALUES (1, 'John')

c)

Both a and b

d)

Neither a nor b

11.

What is the default sort order for ORDER BY when using a text column?

a)

Ascending

b)

Descending

c)

Random

d)

Alphabetical only

12.

How many rows can be inserted using a single INSERT INTO statement?

a)

1

b)

Multiple

c)

0

d)

Depends on the database

13.

Which of the following ORDER BY clauses will sort by the "age" column in descending order?

a)

ORDER BY age ASC

b)

ORDER BY age DESC

c)

ORDER BY age UP

d)

ORDER BY age DOWN

14.

What is required when using INSERT INTO with specified columns?

a)

Values for all columns

b)

Values for specified columns only

c)

No values

d)

Sorted values

15.

Which of the following is true about ORDER BY?

a)

It modifies the table data

b)

It only affects the display order

c)

It deletes rows

d)

It inserts new rows

16.

What happens if you try to insert a duplicate primary key with INSERT INTO?

a)

It inserts the row

b)

It throws an error

c)

It updates the existing row

d)

It sorts the data

17.

Which ORDER BY syntax is invalid?

a)

ORDER BY column_name

b)

ORDER BY 1

c)

ORDER BY column_name, 2 DESC

d)

ORDER BY NULL

18.

How can you insert data into specific columns only?

a)

Omit the column names

b)

Specify column names and provide values

c)

Use ORDER BY

d)

Use DELETE

19.

What is the effect of ORDER BY on a query with no results?

a)

It throws an error

b)

It returns an empty sorted result

c)

It inserts data

d)

It updates data

20.

Which INSERT INTO syntax allows multiple rows?

a)

INSERT INTO table_name (col1, col2) VALUES (val1, val2), (val3, val4)

b)

INSERT INTO table_name VALUES (val1, val2)

c)

Both a and b

d)

Neither a nor b

21.

What is the purpose of specifying column names in INSERT INTO?

a)

To sort the data

b)

To define which columns receive values

c)

To delete columns

d)

To update columns

22.

Which ORDER BY clause sorts by multiple columns?

a)

ORDER BY col1, col2

b)

ORDER BY col1 + col2

c)

ORDER BY (col1, col2)

d)

ORDER BY col1 OR col2

23.

What happens if a value in INSERT INTO exceeds the column's data type limit?

a)

It truncates the value

b)

It throws an error

c)

It sorts the data

d)

It inserts null

24.

Which ORDER BY option is case-sensitive by default?

a)

Yes

b)

No

c)

Depends on collation

d)

Never

25.

What is the minimum requirement for an INSERT INTO statement?

a)

Table name and values

b)

Column names only

c)

ORDER BY clause

d)

WHERE clause

26.

Debug this query: SELECT * FROM students ORDER BY age DESC; (Assume table has columns: id, name)

4 lines
27.

Debug this query: INSERT INTO users (id, name) VALUES ('1', 'John'); (id is INT)

4 lines
28.

Debug this query: SELECT * FROM employees ORDER BY salary UP;

4 lines
29.

Debug this query: INSERT INTO customers VALUES ('1', 'Alice'); (id INT, name VARCHAR)

4 lines
30.

Debug this query: INSERT INTO products (id, price) VALUES (1, '100.50'); (price is DECIMAL)

4 lines
31.

Debug this query: SELECT * FROM staff ORDER BY name, dept; (dept not in SELECT)

4 lines
32.

Debug this query: INSERT INTO employees (id) VALUES ();

4 lines
33.

Debug this query: SELECT * FROM users ORDER BY email DESC, name ASC; (email not in table)

4 lines
34.

Debug this query: INSERT INTO teachers (id, name) VALUES (1, ), (2, 'Bob');

4 lines
35.

Debug this query: SELECT * FROM students ORDER BY grade, age DESC; (grade not in table)

4 lines
36.

Debug this query: INSERT INTO clients (id, name) VALUES (1, NULL); (name is NOT NULL)

4 lines
37.

Debug this query: SELECT * FROM orders ORDER BY total PRICE;

4 lines
38.

Debug this query: INSERT INTO products (id, name) VALUES (1), (2);

4 lines
39.

Debug this query: INSERT INTO users (id, name) VALUES (1, 'John', 'extra');

4 lines
40.

Debug this query: INSERT INTO staff (id) VALUES (1, 'Jane');

4 lines
41.

Debug this query: INSERT INTO students (id, name) VALUES ((1), 'Alice');

4 lines
42.

The ORDER BY clause permanently changes the data in a table.

a)

True

b)

False

43.

You can use ORDER BY with multiple columns in a single query.

a)

True

b)

False

44.

The INSERT INTO statement requires column names to be specified.

a)

True

b)

False

45.

ORDER BY can sort data in ascending order only.

a)

True

b)

False

46.

INSERT INTO can add multiple rows in one statement.

a)

True

b)

False

47.

The default sort order for ORDER BY is descending.

a)

True

b)

False

48.

INSERT INTO will fail if a value violates a primary key constraint.

a)

True

b)

False

49.

ORDER BY affects the underlying table structure.

a)

True

b)

False

50.

You can insert NULL values into a column with INSERT INTO if the column allows NULL.

a)

True

b)

False

51.

The ORDER BY clause must be used with a SELECT statement.

a)

True

b)

False

52.

INSERT INTO can update existing rows.

a)

True

b)

False

53.

You can sort by a column not included in the SELECT list with ORDER BY.

a)

True

b)

False

54.

The INSERT INTO statement requires all columns to have values.

a)

True

b)

False

55.

ORDER BY can sort numeric and text data.

a)

True

b)

False

56.

The DESC keyword reverses the default sort order.

a)

True

b)

False

57.

INSERT INTO can insert data into a view.

a)

True

b)

False

58.

The ORDER BY clause is case-sensitive by default.

a)

True

b)

False

59.

The clause used to sort the result set is _____ __.

(a)  

60.

To insert a new record, use the ______ ____ statement.

(a)  

61.

The keyword (a)   sorts data in descending order.

62.

The default sort order for ORDER BY is (a)   .

63.

To insert multiple rows, use ______ ____ with multiple VALUE sets.

(a)  

64.

The keyword (a)   is used to specify values in an INSERT INTO statement.

65.

ORDER BY can sort by the (a)   position in the SELECT list.

66.

An error occurs in INSERT INTO if a (a)   key constraint is violated.

67.

What will be the output of: SELECT name FROM students ORDER BY age DESC; (age: 20, 15, 25; names: Alice, Bob, Charlie)

(a)  

68.

What will be the output of: SELECT id, name FROM users ORDER BY id; (id: 3, 1, 2; names: Carol, Alice, Bob)

(a)  

69.

What will be the output of: SELECT * FROM employees ORDER BY salary DESC; (salary: 5000, 3000, 4000)

(a)  

70.

What will be the output of: INSERT INTO students (id, name) VALUES (1, 'John');
SELECT * FROM students;

(a)  

71.

What will be the output of: SELECT name FROM teachers ORDER BY name DESC; (names: David, Anna, Bob)

(a)  

72.

What will be the output of: SELECT * FROM products ORDER BY price; (price: 10.5, 5.0, 15.0)

(a)  

73.

What will be the output of: INSERT INTO users (id, name) VALUES (1, 'Alice'), (2, 'Bob');

SELECT * FROM users; (empty table)

(a)  

74.

What will be the output of: SELECT name FROM customers ORDER BY 1; (names: Eve, Adam, Charlie)

(a)  

75.

What will be the output of: INSERT INTO employees (id, name) VALUES (1, 'John'); SELECT name FROM employees;

(a)  

76.

To retrieve all the records from the "users" table, use: SELECT (a)   FROM users;

77.

To update the name column in the users table where id = 1:
UPDATE users SET name = 'John' WHERE (a)   = 1;

78.

Given table students(name, age) with one row: ('Anna', 20). What is the output? SELECT age FROM students WHERE name = 'Anna';

(a)  

79.

What is the error in: INSERT INTO products (id) VALUES ('a'); (id is INT)

4 lines
80.

What is the error in: SELECT * FROM students ORDER BY;

4 lines
81.

What is the error in: INSERT INTO teachers VALUES (1); (id, name columns)

4 lines
82.

What is the error in: INSERT INTO clients (id, name) VALUES (1, 1); (name is VARCHAR)

4 lines
83.

What is the error in: SELECT * FROM orders ORDER BY 0;

4 lines
84.

What is the error in: INSERT INTO students (id, name) VALUES (1, NULL); (name NOT NULL)

4 lines
85.

What is the issue with: INSERT INTO courses (course_id, course_name) VALUES (101, NULL); (course_name NOT NULL)

4 lines
86.

What will be the output of: SELECT name FROM customers ORDER BY age DESC; (age: 30, 30, 25; names: Alice, Bob, Charlie)

(a)  

87.

What will be the output of: INSERT INTO products (id) VALUES (1); SELECT * FROM products; (id INT, name VARCHAR DEFAULT 'Unknown')

4 lines
88.

What is the error in: SELECT * FROM users ORDER BY (email + name); (email VARCHAR, name VARCHAR)

4 lines
89.

What is the error in: INSERT INTO employees (id, salary) VALUES (1, 'invalid'); (salary DECIMAL)

4 lines
90.

What is the issue with: INSERT INTO employees (id, salary) VALUES (2, 'text'); (salary DECIMAL)

4 lines