Here are 1000 MCQs on SQL (Chapterwise).
1. What does SQL stand for?
a) Structured Query Language
b) Standard Query Language
c) Simple Query Language
d) Sequential Query Language
View Answer
Explanation: SQL stands for Structured Query Language. It is a domain-specific language used to manage and manipulate relational databases. SQL provides a standardized way to interact with databases, enabling users to perform tasks such as querying, updating, and managing the structure of databases.
2. Which of the following is NOT a valid keyword in SQL?
a) SELECT
b) DELETE
c) WHERE
d) INCLUDE
View Answer
Explanation: In SQL, “INCLUDE” is not a valid keyword. The correct keywords are:
- SELECT: Used to retrieve data from one or more tables.
- DELETE: Used to delete records from a table.
- WHERE: Used to filter the results based on a specified condition.
“INCLUDE” is not a standard SQL keyword. SQL keywords are reserved words that have specific meanings in the language, and “INCLUDE” is not recognized as one of them in standard SQL syntax.
3. Which of the following operators is used to compare two values in SQL?
a) +
b) =
c) <>
d) &
View Answer
Explanation: The <> operator in SQL is used to compare two values for inequality. It checks if the values on both sides are different.
4. What is the purpose of the SQL keyword “DISTINCT” in a SELECT statement?
a) To retrieve unique values from a column
b) To filter NULL values
c) To delete duplicate records
d) To sort the result set
View Answer
Explanation: The DISTINCT keyword is used to retrieve unique values from a specified column in a SELECT query.
5. Which of the following tasks CANNOT be accomplished using SQL?
a) Creating and modifying database structures
b) Writing complex algorithms for data analysis
c) Retrieving specific data from a database
d) Adding new data to a database
View Answer
Explanation: SQL is not primarily designed for writing complex algorithms for data analysis. Other languages like Python or R are more suitable for this task.
6. Which of the following is basis for SQL?
a) SQL Server
b) DBMS
c) RDBMS
d) Oracle
View Answer
Explanation: RDBMS is the basis for SQL, and for all modern database systems such as MS SQL Server, IBM DB2, Oracle, MySQL and Microsoft Access.
7. Which character is used to separate SQL statements in database systems?
a) :
b) %
c) _
d) ;
View Answer
Explanation: A SQL statement begins with a SQL keyword and ends with a semicolon. Using semicolon is the standard way to separate each SQL statement in database systems.
8. Which statement(s) are mandatory in a simple SQL SELECT statement?
a) Select, From
b) Select, OrderBy
c) Select, Where
d) Select, GroupBy
View Answer
Explanation: From statement contains the table name from which the required columns are to be retrieved. So it is necessary along with Select statement, whereas others are optional.
9. Which of the following is a default join type?
a) Right join
b) Left join
c) Inner join
d) Outer join
View Answer
Explanation: Inner join Selects records that have matching values in both the tables. It’s the default join type, so if we just type JOIN without specifying any other conditions, an INNER JOIN will be used.
10. Which of the following command is used to create a database in SQL?
a) MAKE
b) CREATE
c) INSERT
d) DEVELOP
View Answer
Explanation: The CREATE command is used to create a database in SQL. The same command can be used to create a table within the database. The INSERT command is used to insert data inside the tables.
11. Which of the following statement is true about views in SQL?
a) We can delete but not insert rows in a view
b) We cannot insert and delete rows in a view
c) We can insert but not delete rows in a view
d) We can insert and delete rows in a view
View Answer
Explanation: In SQL, we can insert and delete rows in a view. We can perform insert and update in an updatable view only. Read-only views are not updatable.
12. What is the full form of PL in PL/SQL?
a) Programming Language
b) Programming Logic
c) Procedural Language
d) Procedural Logic
View Answer
Explanation: PL in PL/SQL stands for Procedural Language. It is a block structured language that enables developers to combine the power of SQL with procedural language.
13. Which of the following can execute a trigger in PL/SQL?
a) Oracle server
b) User
c) Both user and oracle server
d) Neither user nor oracle server
View Answer
Explanation: A trigger is automatically executed by the Oracle server whenever a specified event occurs. A user can create and store a trigger and specify when to execute it but the its execution is done by the server automatically.
14. Which of the following SQL statement selects only unique values from ‘section’ column of table ‘school’?
a) SELECT section FROM school;
b) SELECT DISTINCT section FROM school;
c) SELECT * FROM school;
d) SELECT ALL section FROM school;
View Answer
Explanation: Distinct keyword along with Select clause returns only distinct values. All keyword when used with select clause returns all values without eliminating the duplicates. * Results all the fields of a table without eliminating duplicates.
15. Which SQL keyword is used to sort the data returned by a SELECT statement?
a) Group
b) Order
c) Group By
d) Order By
View Answer
Explanation: Order By clause is used to sort the retrieved data in ascending or descending order. Group By clause is used to group the result-set by one or more columns. Order and Group are not valid SQL commands.
16. The SQL LIKE operator is used in which of the following clause?
a) Having
b) Select
c) Where
d) Group by
View Answer
Explanation: The SQL LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
Chapterwise Multiple Choice Questions on SQL
- SQL Basics
- Select Statement
- SQL Clause, Operators and Keywords
- SQL Statements
- SQL Numeric Functions
- SQL Operators and Wildcards
- SQL Joins
- Data Retrieval Techniques
- SQL Subqueries
- SQL Database
- SQL Constraints
- SQL Data Types, Views and Injection
- SQL Hosting, Operators and Data Types
- PL/SQL Basics
- PL/SQL Data Types and Variables
- PL/SQL Constants and Operators
- PL/SQL Loops, Strings and Arrays
- PL/SQL Procedures, Functions and Cursors
- PL/SQL Records, Exceptions and Triggers
- PL/SQL Packages, Collections and Transactions
- PL/SQL Data Types and DBMS Output
1. SQL Questions and Answers on Basics
The section contains multiple choice questions and answers on sql basics and sql syntax.
|
|
2. SQL MCQs on Select Statement
The section contains questions and answers on sql select statement and select distinct statements.
|
|
3. SQL Clause, Operators and Keywords
The section contains MCQs on SQL clauses such as WHERE and SELECT TOP, SQL keywords like ORDER BY, and SQL operators such as AND, OR, and NOT. It also covers topics related to SQL null values.
|
|
4. SQL Multiple Choice Questions on Statements
The section contains multiple choice questions and answers on sql statements like insert, update and delete.
|
|
5. SQL Numeric Functions
The section contains questions and answers on sql numeric functions like min, max, count, avg and sum.
|
|
6. SQL Operators and Wildcards
The section contains MCQs on sql like operator, wildcard characters, aliases, and the IN and BETWEEN SQL operators.
|
|
7. SQL Joins
The section contains multiple choice questions and answers on sql union operator, as well as various joins like inner join, left join, right join, full and self joins.
|
|
8. SQL Questions on Data Retrieval Techniques
The section contains questions and answers on sql group by statement, sql having clause, sql exists operator, sql any and all operators.
|
|
9. SQL Subqueries
The section contains MCQs on sql subqueries, sql statements like select into and insert into, sql null functions and sql comments.
|
|
10. SQL Database
The section contains multiple choice questions and answers on sql database and table creation, sql drop database, sql drop and alter tables.
|
|
11. SQL Constraints
The section contains questions and answers on sql constraints like not null constraint, unique constraint, primary and foreign key constraints, sql check and default constraint, sql create index statement and sql auto-increment field.
|
|
12. SQL Data Types, Views and Injection
The section contains MCQs on sql dates data types, sql view statements and sql injection.
|
|
13. SQL Hosting, Operators and Data Types
The section contains multiple choice questions and answers on sql hosting, sql operators and sql data types.
|
|
14. PL/SQL Basics
The section contains questions and answers on pl/sql basics and syntax.
|
|
15. PL/SQL Data Types and Variables
The section contains MCQs on pl/sql data types and variables.
|
|
16. PL/SQL Constants and Operators
The section contains multiple choice questions and answers on pl/sql constants and literals, pl/sql operators and conditions.
|
|
17. PL/SQL Loops, Strings and Arrays
The section contains questions and answers on pl/sql loops, pl/sql strings and arrays.
|
|
18. PL/SQL Procedures, Functions and Cursors
The section contains MCQs on pl/sql procedures, functions and cursors.
|
|
19. PL/SQL Records, Exceptions and Triggers
The section contains multiple choice questions and answers on pl/sql records, pl/sql exceptions and triggers.
|
|
20. PL/SQL Packages, Collections and Transactions
The section contains questions and answers on pl/sql packages, collections and transactions.
|
|
21. PL/SQL Data Types and DBMS Output
The section contains MCQs on pl/sql dbms output, pl/sql date and time data types.
|
|
Wish you the best in your endeavor to learn and master SQL!
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]