Question : Which SQL statement is used to retrieve data from a database?
SELECT
INSERT
UPDATE
DELETE
Correct Answer : SELECT
Question : What SQL keyword is used to specify the name of a database in SQL queries?
FROM
INTO
DATABASE
USE
Correct Answer : USE
Question : Which SQL keyword is used to filter records based on a condition?
WHERE
HAVING
FILTER
GROUP BY
Correct Answer : WHERE
Question : In SQL, which data type is used to store text of variable length?
INT
VARCHAR
CHAR
TEXT
Correct Answer : VARCHAR
Question : What SQL keyword is used to sort the result set in ascending order?
ASC
SORT
ORDER BY
ASCENDING
Correct Answer : ASC
Question : In SQL, what function is used to count the number of rows in a table?
COUNT
SUM
AVG
MAX
Correct Answer : COUNT
Question : Which SQL statement is used to add new rows to a table?
CREATE
INSERT
ALTER
ADD
Correct Answer : INSERT
Question : What does SQL stand for?
Structured Query Language
Standardized Query Language
Sequential Query Language
Secondary Query Language
Correct Answer : Structured Query Language
Question : Which SQL operator is used to check if a value is within a range?
LIKE
BETWEEN
IN
EXISTS
Correct Answer : BETWEEN
Question : In SQL, which keyword is used to delete a table?
REMOVE
DROP
DELETE
ERASE
Correct Answer : DROP
Question : What SQL keyword is used to remove duplicates from a result set?
DISTINCT
UNIQUE
DISTINCTROW
NO DUPLICATES
Correct Answer : DISTINCT
Question : Which SQL function is used to find the highest value in a column?
MAX
MIN
TOP
HIGH
Correct Answer : MAX
Question : In SQL, which command is used to change the structure of a table?
ALTER TABLE
MODIFY TABLE
CHANGE TABLE
ADJUST TABLE
Correct Answer : ALTER TABLE
Question : What SQL clause is used to group rows that have the same values into summary rows?
WHERE
GROUP BY
HAVING
GROUP WITH
Correct Answer : GROUP BY
Question : In SQL, what function is used to get the current system date and time?
CURRENT_TIMESTAMP
GETDATE
NOW
SYSDATE
Correct Answer : CURRENT_TIMESTAMP
Question : Which SQL command is used to change data in a database?
ALTER
MODIFY
CHANGE
UPDATE
Correct Answer : UPDATE
Question : What SQL keyword is used to create a table?
DEFINE
DECLARE
CREATE
MAKE
Correct Answer : CREATE
Question : In SQL, which command is used to change the name of a table?
RENAME TABLE
CHANGE TABLE
MODIFY TABLE
ALTER TABLE
Correct Answer : ALTER TABLE
Question : What SQL keyword is used to combine the result set of two or more SELECT statements?
UNION
JOIN
MERGE
CONCATENATE
Correct Answer : UNION
Question : In SQL, what keyword is used to specify the type of join to be performed?
TO
BY
WITH
ON
Correct Answer : ON
Question : What type of SQL join returns all rows when there is a match in one of the tables being joined?
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL OUTER JOIN
Correct Answer : INNER JOIN
Question : Which SQL join returns all rows from the left table and the matching rows from the right table, with unmatched rows in the right table having NULL values?
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL OUTER JOIN
Correct Answer : LEFT JOIN
Question : In SQL, which join returns all rows from both tables, joining records where available and putting NULLs where the data is missing?
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL OUTER JOIN
Correct Answer : FULL OUTER JOIN
Question : What SQL join returns all rows from the right table and the matching rows from the left table, with unmatched rows in the left table having NULL values?
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL OUTER JOIN
Correct Answer : RIGHT JOIN
Question : Which type of join in SQL combines the results of both the LEFT JOIN and RIGHT JOIN?
INNER JOIN
LEFT OUTER JOIN
RIGHT OUTER JOIN
FULL OUTER JOIN
Correct Answer : FULL OUTER JOIN
Question : In SQL, what is a view?
A temporary table stored in memory
A virtual table based on the result of a SELECT query
A physical table containing summarized data
A type of index for faster data retrieval
Correct Answer : A virtual table based on the result of a SELECT query
Question : What is the primary purpose of using views in SQL?
To improve database performance
To store frequently used data permanently
To simplify complex queries and provide a layer of abstraction
To enforce data integrity constraints
Correct Answer : To simplify complex queries and provide a layer of abstraction
Question : In SQL, can views be updated directly?
Yes, views can be updated directly
No, views cannot be updated directly
Views can be updated only if they are materialized
Views can be updated, but only with special permissions
Correct Answer : Yes, views can be updated directly
Question : Which SQL statement is used to create a view?
CREATE VIEW
ALTER VIEW
INSERT VIEW
MAKE VIEW
Correct Answer : CREATE VIEW
Question : In SQL, what happens when a view is dropped?
The data in the view is deleted permanently
The view definition is deleted, but the underlying data remains unaffected
The view is disabled but remains in the database
The view is archived for future reference
Correct Answer : The view definition is deleted, but the underlying data remains unaffected
Question : What is the primary purpose of creating indexes in SQL?
To enforce data integrity constraints
To optimize data storage in the database
To improve query performance by facilitating faster data retrieval
To define primary and foreign key relationships
Correct Answer : To improve query performance by facilitating faster data retrieval
Question : In SQL, which type of index enforces uniqueness on a column or a combination of columns?
Clustered index
Non-clustered index
Unique index
Composite index
Correct Answer : Unique index
Question : What is a clustered index in SQL?
An index that stores the data rows in the order of the index key
An index that does not require additional disk space
An index that is created automatically on primary key columns
An index used for sorting data in ascending order
Correct Answer : An index that stores the data rows in the order of the index key
Question : In SQL, what is the disadvantage of having too many indexes on a table?
Increased disk space usage
Slower data retrieval due to index fragmentation
Decreased concurrency in data modification operations
Limited query optimization opportunities
Correct Answer : Increased disk space usage
Question : Which SQL statement is used to create an index?
ADD INDEX
CREATE INDEX
DEFINE INDEX
MAKE INDEX
Correct Answer : CREATE INDEX
Question : Which SQL function is used to return the current database system timestamp?
GETDATE()
NOW()
CURRENT_TIMESTAMP()
SYSDATE()
Correct Answer : CURRENT_TIMESTAMP()
Question : What does the SQL function COUNT() do?
Counts the number of distinct values in a column
Counts the number of NULL values in a column
Counts the number of rows returned by a query
Counts the number of non-NULL values in a column
Correct Answer : Counts the number of rows returned by a query
Question : Which SQL function is used to find the highest value in a column?
MIN()
AVG()
MAX()
SUM()
Correct Answer : MAX()
Question : What does the SQL function AVG() do?
Returns the average value of a numeric column
Returns the median value of a column
Returns the sum of all values in a column
Returns the total count of rows in a table
Correct Answer : Returns the average value of a numeric column
Question : Which SQL function is used to concatenate two or more strings?
CONCAT()
COMBINE()
JOIN()
MERGE()
Correct Answer : CONCAT()
Question : What does the SQL function SUBSTRING() do?
Converts a string to uppercase
Extracts a substring from a string
Converts a string to lowercase
Replaces occurrences of a substring in a string
Correct Answer : Extracts a substring from a string
Question : Which SQL function is used to return the length of a string?
LEN()
LENGTH()
SIZE()
CHAR_LENGTH()
Correct Answer : CHAR_LENGTH()
Question : What does the SQL function UPPER() do?
Converts a string to lowercase
Converts a string to uppercase
Converts a string to title case
Removes leading and trailing spaces from a string
Correct Answer : Converts a string to uppercase
Question : Which SQL function is used to round a numeric value to a specified number of decimal places?
TRUNC()
ROUND()
CEIL()
FLOOR()
Correct Answer : ROUND()
Question : What does the SQL function NOW() do?
Returns the current system date and time
Returns the current system date
Returns the current system time
Returns the current system timestamp
Correct Answer : Returns the current system date and time
Question : Which SQL statement is used to combine the results of two or more SELECT statements?
UNION
JOIN
CONCAT
MERGE
Correct Answer : UNION
Question : What does the SQL GROUP BY clause do?
Groups rows that have the same values into summary rows
Orders the result set in ascending order
Filters rows based on a condition
Joins two or more tables
Correct Answer : Groups rows that have the same values into summary rows
Question : In SQL, which statement is used to remove duplicates from a result set?
UNIQUE
DISTINCT
DIFFERENCE
EXCLUDE DUPLICATES
Correct Answer : DISTINCT
Question : What does the SQL HAVING clause do?
Filters rows based on a condition
Specifies the order of the result set
Groups rows after the WHERE clause
Applies a filter condition to grouped rows
Correct Answer : Applies a filter condition to grouped rows
Question : Which SQL statement is used to modify data in a database?
UPDATE
ALTER
MODIFY
CHANGE
Correct Answer : UPDATE
Question : What is the purpose of the SQL CASE statement?
To create a temporary table
To filter rows based on a condition
To update data in a table
To perform conditional logic in a query
Correct Answer : To perform conditional logic in a query
Question : In SQL, what does the COALESCE function do?
Returns the first non-NULL value in a list of expressions
Returns the last non-NULL value in a list of expressions
Concatenates two or more strings
Returns the number of rows in a result set
Correct Answer : Returns the first non-NULL value in a list of expressions
Question : Which SQL statement is used to add a new column to an existing table?
ADD COLUMN
ALTER TABLE
CREATE COLUMN
MODIFY COLUMN
Correct Answer : ALTER TABLE
Question : What is the purpose of the SQL ROLLUP operator?
To perform a top-down calculation in a hierarchy
To combine the results of two or more SELECT statements
To filter rows based on a condition
To group data in a specified order
Correct Answer : To perform a top-down calculation in a hierarchy
Question : Which SQL statement is used to delete rows from a table based on a condition?
REMOVE
DELETE
DROP
TRUNCATE
Correct Answer : DELETE
Question : What is the purpose of the PRIMARY KEY constraint in SQL?
Ensures that a column can contain unique values and cannot contain NULL values
Defines a default value for a column when no value is specified
Specifies a column or a combination of columns that uniquely identifies each row in a table
Links a column in one table to a column in another table
Correct Answer : Specifies a column or a combination of columns that uniquely identifies each row in a table
Question : In SQL, what is the purpose of the FOREIGN KEY constraint?
Ensures that a column can contain unique values and cannot contain NULL values
Defines a default value for a column when no value is specified
Specifies a column or a combination of columns that uniquely identifies each row in a table
Enforces referential integrity by linking a column in one table to a column in another table
Correct Answer : Enforces referential integrity by linking a column in one table to a column in another table
Question : What is a surrogate key in SQL?
A key that is created by the database management system automatically
A key that is derived from the natural characteristics of the data
A key that is used for encryption purposes
A key that is generated by a user-defined function
Correct Answer : A key that is created by the database management system automatically
Question : In SQL, what is the purpose of the UNIQUE constraint?
Specifies a column or a combination of columns that uniquely identifies each row in a table
Ensures that a column can contain unique values and cannot contain NULL values
Defines a default value for a column when no value is specified
Enforces referential integrity by linking a column in one table to a column in another table
Correct Answer : Ensures that a column can contain unique values and cannot contain NULL values
Question : Which SQL key constraint ensures that a column can contain NULL values but cannot contain duplicate values?
PRIMARY KEY
FOREIGN KEY
UNIQUE
CHECK
Correct Answer : UNIQUE
Question : What is the difference between a primary key and a unique key in SQL?
A primary key can contain NULL values, whereas a unique key cannot.
A primary key is a combination of multiple columns, whereas a unique key is a single column.
A primary key enforces both uniqueness and NOT NULL constraints, whereas a unique key enforces only uniqueness.
There is no difference between a primary key and a unique key.
Correct Answer : A primary key enforces both uniqueness and NOT NULL constraints, whereas a unique key enforces only uniqueness.
Question : What is the purpose of the CHECK constraint in SQL?
Specifies a column or a combination of columns that uniquely identifies each row in a table
Ensures that a column can contain unique values and cannot contain NULL values
Defines a condition that each row must satisfy for the data to be valid
Enforces referential integrity by linking a column in one table to a column in another table
Correct Answer : Defines a condition that each row must satisfy for the data to be valid
Question : Which SQL key constraint allows multiple rows to have NULL values in the specified column?
PRIMARY KEY
FOREIGN KEY
UNIQUE
CHECK
Correct Answer : CHECK
Question : What is the purpose of the INDEX in SQL?
Defines a condition that each row must satisfy for the data to be valid
Specifies a column or a combination of columns that uniquely identifies each row in a table
Enforces referential integrity by linking a column in one table to a column in another table
Improves the performance of SELECT queries by facilitating faster data retrieval
Correct Answer : Improves the performance of SELECT queries by facilitating faster data retrieval
Question : Which SQL key constraint can be used to ensure that a column or combination of columns always contains a value?
PRIMARY KEY
FOREIGN KEY
UNIQUE
NOT NULL
Correct Answer : NOT NULL
Question : Which SQL data type is used to store a fixed-length string?
VARCHAR
TEXT
CHAR
CLOB
Correct Answer : CHAR
Question : What is the maximum length of a VARCHAR data type in SQL?
255 characters
1000 characters
4000 characters
It varies depending on the database system
Correct Answer : It varies depending on the database system
Question : Which SQL data type is used to store large text data?
VARCHAR
TEXT
CLOB
BLOB
Correct Answer : TEXT
Question : In SQL, what is the data type for storing a date and time value?
DATE
TIME
DATETIME
TIMESTAMP
Correct Answer : TIMESTAMP
Question : What is the purpose of the DECIMAL data type in SQL?
To store floating-point numbers with precision and scale
To store large binary objects such as images or documents
To store fixed-point numbers with precision and scale
To store integer values
Correct Answer : To store fixed-point numbers with precision and scale
Question : Which SQL data type is used to store a binary large object?
VARCHAR
BLOB
CLOB
TEXT
Correct Answer : BLOB
Question : What is the difference between the CHAR and VARCHAR data types in SQL?
CHAR stores fixed-length strings, while VARCHAR stores variable-length strings.
CHAR is case-sensitive, while VARCHAR is case-insensitive.
CHAR is for numeric data, while VARCHAR is for text data.
CHAR has a maximum length, while VARCHAR does not.
Correct Answer : CHAR stores fixed-length strings, while VARCHAR stores variable-length strings.
No comments:
Post a Comment