SQL Database Foundations and Basics Quiz

SQL Database
0 Passed
0% acceptance

A 50-question beginner SQL database quiz covering essential SQL commands, data retrieval, table structures, constraints, data types, and simple relational concepts.

50 Questions
~100 minutes
1

Question 1

What is a database primarily used for?

A
Storing and organizing data
B
Only creating user interfaces
C
Rendering animations
D
Designing graphics
2

Question 2

A table in a relational database is best described as:

A
A collection of rows and columns
B
A single image file
C
A stored audio format
D
A programming loop structure
3

Question 3

Which item represents a single record in a table?

A
Column
B
Row
C
Database engine
D
Constraint
4

Question 4

Which SQL category does SELECT belong to?

A
DML
B
DDL
C
DCL
D
TCL
5

Question 5

SQL stands for:

A
Structured Query Language
B
Simple Quick Lookup
C
System Query Level
D
Sequential Question Logic
6

Question 6

Which command adds new data into a table?

A
INSERT
B
SELECT
C
DROP
D
ORDER BY
7

Question 7

Which SQL statement removes rows?

A
DELETE
B
SHOW
C
VIEW
D
DEFINE
8

Question 8

The UPDATE statement is used to:

A
Modify existing data
B
Create a new table
C
Grant permissions
D
Start a transaction
9

Question 9

What does this query return?

sql
SELECT name FROM employees;
A
All employee names
B
Only the first employee
C
All columns from employees
D
No results
10

Question 10

Which of the following is a valid SQL keyword?

A
ORDER BY
B
SORT()
C
ALIGN
D
MATCHER
11

Question 11

Which clause filters rows?

A
WHERE
B
ORDER BY
C
GROUP BY
D
INDEX
12

Question 12

Which operator performs pattern matching?

A
LIKE
B
WITH
C
FROM
D
JOIN
13

Question 13

What does this query return?

sql
SELECT * FROM products WHERE price > 100;
A
All products with price greater than 100
B
Products with price equal to 100
C
All product names only
D
Nothing; query is invalid
14

Question 14

What does ORDER BY do?

A
Sorts results
B
Deletes rows
C
Renames columns
D
Creates a table
15

Question 15

A primary key is used to:

A
Uniquely identify each row
B
Sort data alphabetically
C
Create a new database
D
Encrypt sensitive information
16

Question 16

What does a foreign key represent?

A
A link to a primary key in another table
B
Randomly generated numbers
C
A column always containing text
D
A system error code
17

Question 17

What will this query return?

sql
SELECT id, email FROM users WHERE active = 1;
A
IDs and emails for active users
B
All users regardless of status
C
Only emails
D
No rows because active cannot equal 1
18

Question 18

A table column describing data type rules is called:

A
Schema
B
Function
C
Trigger
D
Procedure
19

Question 19

Which clause groups rows before applying aggregate functions?

A
GROUP BY
B
SORT
C
BREAK
D
UNION
20

Question 20

What does this query calculate?

sql
SELECT COUNT(*) FROM orders;
A
The total number of rows in orders
B
The number of columns
C
The highest order value
D
A list of customers
21

Question 21

Which join returns only matching rows from both tables?

A
INNER JOIN
B
LEFT JOIN
C
FULL JOIN
D
CROSS JOIN
22

Question 22

A LEFT JOIN will return:

A
All rows from the left table plus matching ones from the right
B
Only rows present in both tables
C
No rows unless every row matches
D
Only right-table data
23

Question 23

What does this join accomplish?

sql

          SELECT customers.name, orders.total
          FROM customers
          INNER JOIN orders ON customers.id = orders.customer_id;
        
A
Shows customers who have placed orders
B
Shows all customers regardless of orders
C
Deletes customers with no orders
D
Returns orders but not customer names
24

Question 24

NULL represents:

A
Absence of a value
B
Zero
C
False
D
An empty string
25

Question 25

Which comparison with NULL evaluates as true?

A
NULL IS NULL
B
NULL = NULL
C
NULL > 0
D
NULL < 0
26

Question 26

What does this query return?

sql
SELECT * FROM users WHERE name LIKE 'A%';
A
Users whose names start with A
B
Users whose names end with A
C
Users whose names contain no letter A
D
All users in the table
27

Question 27

Which data type is commonly used for text?

A
VARCHAR
B
INT
C
DATE
D
BOOLEAN
28

Question 28

Which data type is used to store whole numbers?

A
INT
B
CHAR
C
FLOAT
D
BLOB
29

Question 29

A NOT NULL constraint means:

A
The column must always contain a value
B
The column can be empty sometimes
C
Values must be unique
D
The column automatically sorts itself
30

Question 30

A UNIQUE constraint ensures:

A
No two rows share the same value
B
Values must be numeric
C
Rows remain sorted
D
Rows cannot be updated
31

Question 31

A company needs to track customers and their orders. Which statement is true in a simple relational model?

A
Customers typically relate to many orders
B
Each customer can only have one order
C
Orders do not link to customers
D
Customers must share the same ID
32

Question 32

Why should related tables use foreign keys?

A
To ensure referenced rows exist
B
To make queries execute faster always
C
To remove the need for primary keys
D
To disable sorting
33

Question 33

What does this query do?

sql

          DELETE FROM products
          WHERE discontinued = 1;
        
A
Removes rows where discontinued is 1
B
Drops the products table
C
Updates the discontinued flag to 0
D
Returns all discontinued products
34

Question 34

Which clause limits how many rows a query returns?

A
LIMIT
B
CONSTRAIN
C
REDUCE
D
STOP
35

Question 35

What happens if you run SELECT * on a large table?

A
It returns all columns for all rows
B
It only returns the first row
C
It deletes the table
D
It hides NULL values
36

Question 36

What does this query return?

sql
SELECT name FROM employees ORDER BY name DESC;
A
Names sorted from Z to A
B
Names sorted A to Z
C
Names with duplicates removed
D
No names because DESC is invalid
37

Question 37

Which statement describes normalization?

A
Organizing data to reduce redundancy
B
Encrypting columns for safety
C
Turning tables into images
D
Adding indexes to speed up queries
38

Question 38

Indexes are mainly used to:

A
Speed up searching on columns
B
Store images
C
Sort tables automatically
D
Make tables smaller
39

Question 39

What does this SQL do?

sql
UPDATE users SET active = 0 WHERE last_login < '2023-01-01';
A
Marks older accounts as inactive
B
Deletes users before 2023
C
Returns only active users
D
Creates a new table for inactive users
40

Question 40

Which statement starts a transaction?

A
BEGIN
B
STARTUP
C
RUN
D
QUEUE
41

Question 41

COMMIT is used to:

A
Save all changes in a transaction
B
Undo all changes
C
Create a backup
D
Close the database
42

Question 42

ROLLBACK is used when:

A
You want to undo changes in a transaction
B
You want to speed up queries
C
You want to index a column
D
You want to import new tables
43

Question 43

What does this query do?

sql
SELECT DISTINCT city FROM users;
A
Returns unique city names only
B
Deletes duplicate cities
C
Sorts city values alphabetically
D
Creates a new column
44

Question 44

Which keyword combines results from two SELECT statements?

A
UNION
B
JOIN
C
MERGE
D
CONNECT
45

Question 45

An empty string ('') is:

A
A value that is not NULL
B
Always equal to NULL
C
A number
D
A system error
46

Question 46

Which clause renames a column in a result?

A
AS
B
RENAME
C
CHANGE
D
MAP
47

Question 47

Which statement deletes an entire table?

A
DROP TABLE
B
DELETE TABLE
C
ERASE TABLE
D
CLEAR TABLE
48

Question 48

Which keyword returns the largest value in a numeric column?

A
MAX
B
TOP
C
LARGEST
D
PEAK
49

Question 49

Why should column types be chosen carefully?

A
To ensure correct storage and efficient queries
B
To decorate the database visually
C
To prevent the need for constraints
D
To auto-generate user interfaces
50

Question 50

Why are SQL databases widely used?

A
They handle structured data predictably and reliably
B
They generate graphics automatically
C
They run faster than all other systems always
D
They replace programming languages entirely

QUIZZES IN SQL Database