Showing 1–10 of 19 questions
in SQL Basics
Which SQL command is used to retrieve data from a database?
A
SELECT
B
RETRIEVE
C
GET
D
FETCH
Correct Answer:
A. SELECT
Explanation:
SELECT is the standard SQL command used to retrieve or query data from one or more tables in a database.
What does the WHERE clause do in SQL?
A
Sorts the results
B
Filters rows based on specified conditions
C
Groups the data
D
Joins multiple tables
Correct Answer:
B. Filters rows based on specified conditions
Explanation:
The WHERE clause is used to filter records that meet specified conditions in a SQL query.
Which keyword is used to eliminate duplicate rows in SQL results?
A
UNIQUE
B
DISTINCT
C
DIFFERENT
D
EXCLUDE
Correct Answer:
B. DISTINCT
Explanation:
The DISTINCT keyword removes duplicate rows from the result set of a query.
What is the correct syntax for inserting data into a table?
A
INSERT INTO table_name VALUES (value1, value2, value3);
B
INSERT table_name (value1, value2, value3);
C
ADD INTO table_name VALUES (value1, value2, value3);
D
INSERT VALUES table_name (value1, value2, value3);
Correct Answer:
A. INSERT INTO table_name VALUES (value1, value2, value3);
Explanation:
INSERT INTO is the correct SQL syntax for inserting new records into a table, followed by the table name and VALUES clause.
Which SQL aggregate function returns the total sum of a numeric column?
A
TOTAL()
B
ADD()
C
SUM()
D
COUNT()
Explanation:
The SUM() function calculates the total sum of all values in a numeric column.
What will be the output of: SELECT COUNT(*) FROM employees;
A
The number of columns in the employees table
B
The total number of rows in the employees table
C
The names of all employees
D
An error message
Correct Answer:
B. The total number of rows in the employees table
Explanation:
COUNT(*) returns the total number of rows in the specified table, including NULL values.
Which statement is used to modify existing data in a table?
A
MODIFY
B
CHANGE
C
UPDATE
D
ALTER
Correct Answer:
C. UPDATE
Explanation:
The UPDATE statement is used to modify existing records in a table.
In SQL, which clause is used to filter groups based on aggregate function results?
A
HAVING
B
WHERE
C
GROUP BY
D
FILTER
Correct Answer:
A. HAVING
Explanation:
HAVING clause filters groups created by GROUP BY, while WHERE filters individual rows before grouping.
Which data type in SQL is used to store large text documents or binary data?
A
VARCHAR
B
TEXT
C
BLOB
D
CLOB
Explanation:
BLOB (Binary Large Object) stores large binary data. CLOB stores large text. TEXT is limited compared to BLOB/CLOB.
What is the purpose of the DISTINCT keyword in SQL?
A
To sort results in ascending order
B
To remove duplicate rows from results
C
To limit the number of rows returned
D
To group rows by column values
Correct Answer:
B. To remove duplicate rows from results
Explanation:
DISTINCT eliminates duplicate rows from query results, ensuring each unique combination appears only once.