SQL Multiple Choice Questions With Answers

Reviewed by Godwin Iheuwa
Godwin Iheuwa, MS (Computer Science) |
Database Administrator
Review Board Member
Godwin Iheuwa, a Database Administrator at MTN Nigeria, holds an MS in Computer Science, specializing in Agile Methodologies and Database Administration from the University of Bedfordshire and a Bachelor's in Computer Science from the University of Port Harcourt. His proficiency in SQL Server Integration Services (SSIS) and SQL Server Management Studio contributes to his expertise in database management.
, MS (Computer Science)
Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Aparnasunil75
A
Aparnasunil75
Community Contributor
Quizzes Created: 20 | Total Attempts: 40,152
Questions: 20 | Attempts: 11,612

SettingsSettingsSettings
SQL Multiple Choice Questions With Answers - Quiz

Are you looking for some SQL multiple-choice questions with answers to make your preparation level better for the upcoming exam? Try our quiz below and see if you know the basics of SQL programming language or not. SQL is the full form of the structured query language designed to work with databases. If you know the basics of SQL, this quiz will not be easy for you. You can test your SQL skills with us by taking the test. Go for it, then!


Questions and Answers
  • 1. 

    Which commands are used to define or redefine schema objects? 

    • A.

      DDL

    • B.

      DML

    • C.

      TCL

    • D.

      (a) & (b) both

    Correct Answer
    A. DDL
    Explanation
    DDL stands for Data Definition Language and is used to define or redefine schema objects in a database. This includes creating, altering, and dropping tables, views, indexes, and other database objects. DDL commands are used to define the structure of the database and its objects, such as defining the columns and data types of a table. Therefore, the correct answer is DDL.

    Rate this question:

  • 2. 

    Which is a valid CREATE TABLE statement? 

    • A.

      Create table emp add(id integer(3));

    • B.

      Create table emp (id integers(3));

    • C.

      Create table emp modified (id integer(3));

    • D.

      Create table emp (id integer(3));

    Correct Answer
    D. Create table emp (id integer(3));
    Explanation
    The correct answer is "Create table emp (id integer(3));". This is a valid CREATE TABLE statement because it follows the correct syntax for creating a table named "emp" with a column "id" of data type "integer" and a length of 3.

    Rate this question:

  • 3. 

    How can you insert a new row into the “STORE” table. 

    • A.

      INSERT ROW (1,‟ RAM SINGH‟) INTO STORE;

    • B.

      INSERT VALUES (1,‟ RAM SINGH‟) INTO STORE;

    • C.

      INSERT INTO (1,‟ RAM SINGH‟) STORE;

    • D.

      INSERT INTO STORE VALUES (1,‟ RAM SINGH‟);

    Correct Answer
    D. INSERT INTO STORE VALUES (1,‟ RAM SINGH‟);
    Explanation
    The correct answer is "INSERT INTO STORE VALUES (1,‟ RAM SINGH‟);" because it follows the correct syntax for inserting a new row into a table. The "INSERT INTO" statement is used to specify the table name, followed by the "VALUES" keyword to indicate the values to be inserted. The values are then enclosed in parentheses and separated by commas.

    Rate this question:

  • 4. 

    Conditionally retrieval of rows from a table with SELECT, which clause is used? 

    • A.

      Where

    • B.

      Having

    • C.

      Group By

    • D.

      Order by

    Correct Answer
    A. Where
    Explanation
    The "WHERE" clause is used for conditionally retrieving rows from a table with the SELECT statement. It allows you to specify conditions that the retrieved rows must meet in order to be included in the result set. The WHERE clause is followed by a condition that evaluates to true or false for each row in the table, and only the rows that satisfy the condition are returned in the result set. This clause is essential for filtering and narrowing down the data that is retrieved from the table.

    Rate this question:

  • 5. 

    The ……………. keyword eliminates duplicate rows from the result of a SELECT statement. 

    • A.

      All

    • B.

      Unique

    • C.

      Distinct

    • D.

      IN

    Correct Answer
    C. Distinct
    Explanation
    The "Distinct" keyword eliminates duplicate rows from the result of a SELECT statement. When used in a query, it ensures that only unique values are returned, removing any duplicate rows that may be present in the result set. This is helpful when you want to retrieve only unique records from a table or when you need to perform calculations or analysis on distinct values.

    Rate this question:

  • 6. 

    Which operator defines a range of values that the column values must fall in? 

    • A.

      In

    • B.

      Like

    • C.

      Between

    • D.

      IS

    Correct Answer
    C. Between
    Explanation
    The operator "Between" is used to define a range of values that the column values must fall in. It is typically used in SQL queries to specify a range for a particular column. For example, "SELECT * FROM table WHERE column BETWEEN value1 AND value2" will retrieve all rows where the column value falls between value1 and value2.

    Rate this question:

  • 7. 

    To specify a list of values …………. Operator is used. 

    • A.

      IN

    • B.

      Like

    • C.

      Between

    • D.

      IS

    Correct Answer
    A. IN
    Explanation
    The IN operator is used to specify a list of values. It allows you to check if a value matches any value in a list. For example, if you have a list of cities (New York, London, Paris) and you want to retrieve all the rows where the city is either New York or Paris, you can use the IN operator. This operator simplifies the query and makes it more efficient compared to using multiple OR conditions.

    Rate this question:

  • 8. 

    Which SQL statement will not generate any error message? 

    • A.

      SELECT * FROM EMP WHERE EMPNO LIKE (1,2,3,4);

    • B.

      SELECT * FROM EMP WHERE SAL BETWEEN 3000 TO 15000;

    • C.

      SELECT * FROM EMP WHERE COMM IS NOT NULL;

    • D.

      All of the above

    Correct Answer
    C. SELECT * FROM EMP WHERE COMM IS NOT NULL;
    Explanation
    The SQL statement "SELECT * FROM EMP WHERE COMM IS NOT NULL;" will not generate any error message because it is a valid query that retrieves all records from the EMP table where the COMM column is not null. The other options in the question have syntax errors that would result in error messages.

    Rate this question:

  • 9. 

    Which statement is valid? 

    • A.

      ALTER TABLE EMPLOYEE MODIFY (last_name CHAR2(2000));

    • B.

      ALTER TABLE EMPLOYEE CHANGE (last_name CHAR2(2000));

    • C.

      ALTER TABLE EMPLOYEE CHANGE (last_name VARCHAR2 (2000));

    • D.

      ALTER TABLE EMPLOYEE MODIFY (last_name VARCHAR2 (2000));

    Correct Answer
    D. ALTER TABLE EMPLOYEE MODIFY (last_name VARCHAR2 (2000));
    Explanation
    The correct answer is "ALTER TABLE EMPLOYEE MODIFY (last_name VARCHAR2 (2000));". This statement is valid because it uses the correct syntax to modify the column "last_name" in the table "EMPLOYEE" to have a maximum length of 2000 characters using the VARCHAR2 data type. The other statements either use incorrect syntax or incorrect data types.

    Rate this question:

  • 10. 

    The clause which sorts data of table.

    • A.

      Group by clause

    • B.

      Having clause

    • C.

      Order by Clause

    • D.

      Where Clause

    Correct Answer
    C. Order by Clause
    Explanation
    The Order by clause is used to sort the data of a table in a specific order. It allows you to arrange the result set in ascending or descending order based on one or more columns. This clause is commonly used in conjunction with the Select statement to organize the output according to certain criteria. By specifying the column(s) to sort by and the desired order, you can easily arrange the data in a meaningful way for analysis or presentation.

    Rate this question:

  • 11. 

    Which of the following commands should be used to create a database named “student”?

    • A.

      CREATE ?I student

    • B.

      CREATE DATABASE student

    • C.

      DATABASE /student

    • D.

      DATABASE student

    Correct Answer
    B. CREATE DATABASE student
    Explanation
    The correct answer is "CREATE DATABASE student" because the "CREATE DATABASE" command is used to create a new database, and "student" is the name specified for the new database.

    Rate this question:

  • 12. 

    Which one will delete the table data as well as the table structure?

    • A.

      DROP

    • B.

      TRUNCATE

    • C.

      Alter

    • D.

      Delete

    Correct Answer
    A. DROP
    Explanation
    DROP is the correct answer because it is a SQL command used to delete both the table data and the table structure. When the DROP command is executed on a table, it removes the entire table from the database, including all the data and the structure of the table. This operation cannot be undone, so it should be used with caution.

    Rate this question:

  • 13. 

    Full form of RDBMS is

    • A.

      Regional district management system

    • B.

      Relational database management system

    • C.

      Regular database management system

    • D.

      Regular district machine system

    Correct Answer
    B. Relational database management system
    Explanation
    The correct answer is "Relational database management system". RDBMS stands for Relational Database Management System, which is a software system that allows users to create, manage, and manipulate relational databases. It is a widely used approach for organizing and storing data in a structured manner, using tables with rows and columns to represent entities and their relationships. RDBMSs provide a set of tools and features for data storage, retrieval, and manipulation, ensuring data integrity and consistency.

    Rate this question:

  • 14. 

    The USE command?

    • A.

      Is used to load code from another file

    • B.

      Has been deprecated and should be avoided for security reasons

    • C.

      Is a pseudonym for the SELECT command

    • D.

      Should be used to choose the database you want to use once you've connected to MySQL

    Correct Answer
    D. Should be used to choose the database you want to use once you've connected to MySQL
    Explanation
    The USE command should be used to choose the database you want to use once you've connected to MySQL. This command allows you to switch to a specific database and perform operations on it. It is important to select the appropriate database before executing any queries to ensure that the operations are performed on the correct database.

    Rate this question:

  • 15. 

    A row of relation is generally referred to as ……….. and a column of a relation is ………… 

    • A.

      Domain & Attribute

    • B.

      Attribute & Domain

    • C.

      Tuple & Attribute

    • D.

      Attribute & Tuple

    Correct Answer
    C. Tuple & Attribute
    Explanation
    A row in a relation is commonly referred to as a tuple, while a column is referred to as an attribute.

    Rate this question:

  • 16. 

    A relation has 45 tuples & 5 attributes. What will be the Degree and Cardinality of that relation? 

    • A.

      Degree 5, Cardinality 45

    • B.

      Degree 45, Cardinality 5

    • C.

      Degree 50, Cardinality 45

    • D.

      Degree 50, Cardinality 2250

    Correct Answer
    A. Degree 5, Cardinality 45
    Explanation
    The degree of a relation refers to the number of attributes or columns in the relation. In this case, the relation has 5 attributes, so the degree is 5. The cardinality of a relation refers to the number of tuples or rows in the relation. Here, the relation has 45 tuples, so the cardinality is 45.

    Rate this question:

  • 17. 

    We use …………… operator with select for condition based on pattern matching.

    • A.

      IN

    • B.

      LIKE

    • C.

      BETWEEN

    • D.

      IS

    Correct Answer
    B. LIKE
    Explanation
    The LIKE operator is used with SELECT for conditions based on pattern matching. It allows us to search for a specified pattern within a column. It uses wildcard characters such as % (represents zero or more characters) and _ (represents a single character) to match patterns. This operator is commonly used in SQL queries to filter and retrieve data based on specific patterns or values.

    Rate this question:

  • 18. 

    To display the detail of employee having „e‟ in their name in descending order of salary the correct SQL statement is :

    • A.

      SELECT * FROM emp WHERE ename LIKE „e%‟ ORDER BY SAL ;

    • B.

      SELECT * FROM emp ORDER BY SAL DESCWHERE ename LIKE „%e%‟;

    • C.

      SELECT * FROM emp WHERE ename LIKE „%e%‟ ORDER BY DESCSAL;

    • D.

      SELECT * FROM emp WHERE ename LIKE „%e%‟ ORDER BY SAL DESC;

    Correct Answer
    D. SELECT * FROM emp WHERE ename LIKE „%e%‟ ORDER BY SAL DESC;
    Explanation
    The correct SQL statement is "SELECT * FROM emp WHERE ename LIKE '%e%' ORDER BY SAL DESC;" This statement selects all the columns from the "emp" table where the "ename" column contains the letter "e" anywhere in the name. It then orders the result in descending order of the "SAL" column.

    Rate this question:

  • 19. 

    _________is the attribute or group of attributes that uniquely identify occurrence of each entity.

    • A.

      Foreign key

    • B.

      Super Key

    • C.

      Primary Key

    • D.

      All of these

    Correct Answer
    C. Primary Key
    Explanation
    A primary key is the attribute or group of attributes that uniquely identify each occurrence of an entity. It serves as a unique identifier for each record in a database table, ensuring that no two records have the same key value. This key is crucial for maintaining data integrity and establishing relationships between tables in a relational database system. By defining a primary key, we can enforce uniqueness and facilitate efficient data retrieval and manipulation operations.

    Rate this question:

  • 20. 

    A non-key attribute whose values are derived from the primary key of some other table. 

    • A.

      Alternate key

    • B.

      Foreign key

    • C.

      Primary key

    • D.

      Super Key

    Correct Answer
    B. Foreign key
    Explanation
    A foreign key is a non-key attribute that is derived from the primary key of another table. It establishes a relationship between two tables by referencing the primary key of one table in another table. This allows for data consistency and integrity, as it ensures that the values in the foreign key column correspond to existing values in the referenced primary key column.

    Rate this question:

Godwin Iheuwa |MS (Computer Science) |
Database Administrator
Godwin Iheuwa, a Database Administrator at MTN Nigeria, holds an MS in Computer Science, specializing in Agile Methodologies and Database Administration from the University of Bedfordshire and a Bachelor's in Computer Science from the University of Port Harcourt. His proficiency in SQL Server Integration Services (SSIS) and SQL Server Management Studio contributes to his expertise in database management.

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Jun 17, 2024
    Quiz Edited by
    ProProfs Editorial Team

    Expert Reviewed by
    Godwin Iheuwa
  • Mar 04, 2020
    Quiz Created by
    Aparnasunil75

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.