This set of SQL Server Multiple Choice Questions & Answers (MCQs) focuses on “Basic SQL – 1”.
1. Which SQL function is used to count the number of rows in a SQL query ?
Explanation:COUNT(*) takes null value row in to consideration.
2. Which SQL keyword is used to retrieve a maximum value ?
Explanation:The MAX() function returns the largest value of the selected column.
3. Which of the following SQL clauses is used to DELETE tuples from a database table ?
Explanation:The SQL DELETE Query is used to delete the existing records from a table.
4. ___________removes all rows from a table without logging the individual row deletions.
Explanation:TRUNCATE statement is a Data Definition Language (DDL) operation that marks the extents of a table for deallocation.
5. Which of the following is not a DDL command ?
d) None of the Mentioned
Explanation: Data definition language (DDL) commands enable you to perform the following tasks:Create, alter, and drop schema objects.
6. Which of the following are TCL commands ?
a) UPDATE and TRUNCATE
b) SELECTand INSERT
c) GRANT and REVOKE.
d) ROLLBACK and SAVEPOINT.
Explanation:Transaction control commands manage changes made by DML commands. These SQL commands are used for managing changes affecting the data.
7. ________________ is not a category of SQL command.
Explanation: SQL commands can be used not only for searching the database but also to perform various other functions.They are DDL,DML,TCL and DCL.
8. If you don’t specify ASC or DESC after a SQL ORDER BY clause, the following is used by default
c) There is no default value
d) None of the mentioned
Explanation: ASC is the default sort order. Null values are treated as the lowest possible values.
9. Which of the following statement is true ?
a) DELETE does not free the space containing the table and TRUNCATE free the space containing the table.
b) Both DELETE and TRUNCATE free the space containing the table.
c) Both DELETE and TRUNCATE does not free the space containing the table.
d) DELETE free the space containing the table and TRUNCATE does not free the space containing the table.
Explanation:The SQL TRUNCATE command is used to delete all the rows from the table and free the space containing the table.
10. What is the purpose of the SQL AS clause ?
a) The AS SQL clause is used change the name of a column in the result set or to assign a name to a derived column.
b) The AS clause is used with the JOIN clause only.
c) The AS clause defines a search condition.
d) All of the mentioned
Explanation: SQL Aliases are defined for columns and tables. Basically aliases is created to make the column selected more readable.
Sanfoundry Global Education & Learning Series – SQL Server.