Back-End Development Development Technical (SQL) 4 — Questions and Answers
Question 1: What does DDL stand for in the context of SQL?
- Data Definition Language (Correct answer)
- Data Deletion Language
- Dynamic Data Linking
- Declarative Database Logic
Correct answer: Data Definition Language
DDL (Data Definition Language) includes statements like CREATE, ALTER, DROP, and TRUNCATE that define or modify database schema structure.
Question 2: Which SQL JOIN type returns only rows where there is a match in BOTH tables?
- LEFT JOIN
- RIGHT JOIN
- FULL OUTER JOIN
- INNER JOIN (Correct answer)
Correct answer: INNER JOIN
INNER JOIN returns only the rows for which the join condition is satisfied in both tables, excluding non-matching rows from either side.
Question 3: What problem does database normalization primarily aim to solve?
- Query execution speed
- Data redundancy and update anomalies (Correct answer)
- Network latency between client and server
- Index bloat from too many columns
Correct answer: Data redundancy and update anomalies
Normalization organizes data to reduce redundancy and prevent insert, update, and delete anomalies by ensuring each fact is stored once.
Question 4: Which SQL function converts a string to uppercase?
- UPPER() (Correct answer)
- CAPITALIZE()
- STRTOUPPER()
- TOUPPER()
Correct answer: UPPER()
UPPER() is the standard SQL function that converts all characters in a string to their uppercase equivalents.
Question 5: What is a SQL VIEW?
- A physical copy of table data stored separately
- A named stored query that can be used like a table (Correct answer)
- An index that speeds up SELECT operations
- A trigger that fires on SELECT statements
Correct answer: A named stored query that can be used like a table
A VIEW is a saved SQL query given a name; when queried, the database executes the underlying SELECT and returns results as if from a table.
Question 6: In SQL, what does the BETWEEN operator include?
- Only values strictly greater than the lower bound and strictly less than the upper bound
- Both the lower and upper boundary values (inclusive) (Correct answer)
- Only the lower boundary value
- Values excluding both boundaries
Correct answer: Both the lower and upper boundary values (inclusive)
BETWEEN is inclusive on both ends, so 'WHERE age BETWEEN 18 AND 65' includes rows where age equals exactly 18 or exactly 65.
Question 7: Which SQL statement is used to remove all rows from a table quickly without logging individual row deletions?
- DELETE FROM table_name
- DROP TABLE table_name
- TRUNCATE TABLE table_name (Correct answer)
- REMOVE ALL FROM table_name
Correct answer: TRUNCATE TABLE table_name
TRUNCATE TABLE removes all rows by deallocating data pages rather than logging each row deletion, making it much faster than DELETE for large tables.
What does DDL stand for in the context of SQL?