SQL MCQ Exam: Trivia Quiz!

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 Abdul
A
Abdul
Community Contributor
Quizzes Created: 8 | Total Attempts: 22,535
Questions: 25 | Attempts: 1,911

SettingsSettingsSettings
SQL MCQ Exam: Trivia Quiz! - Quiz

.


Questions and Answers
  • 1. 

    Which of the following statements contains an error?

    • A.

      SELECT * FROM emp WHERE empid = 493945;

    • B.

      SELECT empid FROM emp WHERE empid= 493945;

    • C.

      SELECT empid FROM emp;

    • D.

      SELECT empid WHERE empid = 56949 AND lastname = ‘SMITH’;

    Correct Answer
    D. SELECT empid WHERE empid = 56949 AND lastname = ‘SMITH’;
    Explanation
    The error in the statement "SELECT empid WHERE empid = 56949 AND lastname = ‘SMITH’;" is that it is missing the "FROM" keyword. In a SELECT statement, the syntax requires specifying the table from which the data is being selected. In this case, the correct statement should be "SELECT empid FROM emp WHERE empid = 56949 AND lastname = ‘SMITH’;".

    Rate this question:

  • 2. 

    Which SQL statement is used to extract data from a Table?

    • A.

      SELECT

    • B.

      GET

    • C.

      OPEN

    • D.

      EXTRACT

    Correct Answer
    A. SELECT
    Explanation
    The SQL statement "SELECT" is used to extract data from a table. It allows you to retrieve specific columns or rows from a table based on specified conditions. By using the SELECT statement, you can retrieve data from one or multiple tables, apply filters, sort the results, and perform other operations to manipulate the data.

    Rate this question:

  • 3. 

    Which SQL statement is used to update data in a Table?

    • A.

      SAVE

    • B.

      MODIFY

    • C.

      UPDATE

    • D.

      SAVE AS

    Correct Answer
    C. UPDATE
    Explanation
    The correct answer is UPDATE. The UPDATE statement is used in SQL to modify or update existing data in a table. It allows you to change the values of one or more columns in a specific row or multiple rows of a table. This statement is essential for making changes to the data stored in a database table.

    Rate this question:

  • 4. 

    With SQL, how do you select a column named "FirstName" from a table named "Persons"?                  

    • A.

      SELECT Persons. FirstName

    • B.

      EXTRACT FirstName FROM Persons

    • C.

      SELECT FirstName FROM Persons

    • D.

      SELECT First Name FROM persons

    Correct Answer
    C. SELECT FirstName FROM Persons
    Explanation
    To select a column named "FirstName" from a table named "Persons" in SQL, you would use the query "SELECT FirstName FROM Persons". This query specifies the column "FirstName" that you want to select from the table "Persons".

    Rate this question:

  • 5. 

    With SQL, how do you select all the columns from a table named "Persons"?              

    • A.

      SELECT [all] FROM Persons

    • B.

      SELECT Persons

    • C.

      SELECT *.Persons

    • D.

      SELECT * FROM Persons

    Correct Answer
    D. SELECT * FROM Persons
    Explanation
    To select all the columns from a table named "Persons" in SQL, you would use the syntax "SELECT * FROM Persons". The asterisk (*) is a wildcard character that represents all columns in the table. By using this query, you will retrieve all the data from every column in the "Persons" table.

    Rate this question:

  • 6. 

    With SQL, how can you insert a new record into the "Persons" table?

    • A.

      INSERT ('Jimmy', 'Jackson') INTO Persons

    • B.

      INSERT VALUES ('Jimmy', 'Jackson') INTO Persons

    • C.

      INSERT INTO Persons VALUES ('Jimmy', 'Jackson')

    • D.

      INSERT Persons values ('Jimmy', 'Jackson')

    Correct Answer
    C. INSERT INTO Persons VALUES ('Jimmy', 'Jackson')
    Explanation
    The correct answer is "INSERT INTO Persons VALUES ('Jimmy', 'Jackson')". This is the correct syntax for inserting a new record into the "Persons" table in SQL. The VALUES keyword is used to specify the values to be inserted, and they are enclosed in parentheses and separated by commas. The INSERT INTO statement is used to indicate the table where the record should be inserted.

    Rate this question:

  • 7. 

    With SQL, how can you insert "Olsen" as the "LastName" in the "Persons" table?

    • A.

      INSERT INTO Persons ('Olsen') INTO LastName

    • B.

      INSERT INTO Persons (LastName) VALUES ('Olsen')

    • C.

      INSERT ('Olsen') INTO Persons (LastName)

    • D.

      INSERT IN Persons ('Olsen') INTO LastName

    Correct Answer
    B. INSERT INTO Persons (LastName) VALUES ('Olsen')
    Explanation
    The correct answer is "INSERT INTO Persons (LastName) VALUES ('Olsen')". This is the correct syntax for inserting a new row into the "Persons" table with the value "Olsen" in the "LastName" column. The keyword "INSERT INTO" is used to specify the table to insert into, followed by the column names in parentheses. The keyword "VALUES" is used to specify the values to be inserted, with each value enclosed in single quotes.

    Rate this question:

  • 8. 

    How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table?                

    • A.

      UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'

    • B.

      MODIFY Persons SET LastName='Hansen' INTO LastName='Nilsen

    • C.

      UPDATE Persons SET LastName='Hansen' INTO LastName='Nilsen'

    • D.

      MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen'

    Correct Answer
    A. UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'
    Explanation
    The correct answer is "UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'". This is the correct SQL statement to update the value of the LastName column from "Hansen" to "Nilsen" in the Persons table. The UPDATE keyword is used to modify data in a table, followed by the table name (Persons) and the SET keyword to specify the column to be updated. The WHERE clause is used to specify the condition that must be met for the update to occur, in this case, the LastName must be "Hansen".

    Rate this question:

  • 9. 

    With SQL, how can you delete the records where the "FirstName" is "Peter" in the Persons Table?

    • A.

      DELETE FROM Persons WHERE FirstName = 'Peter'

    • B.

      DELETE FirstName='Peter' FROM Persons

    • C.

      DELETE ROW FirstName='Peter' FROM Persons

    • D.

      DELETE Persons WHERE FirstName = 'Peter'

    Correct Answer
    A. DELETE FROM Persons WHERE FirstName = 'Peter'
    Explanation
    The correct answer is "DELETE FROM Persons WHERE FirstName = 'Peter'". This statement is the correct syntax for deleting records from the "Persons" table where the "FirstName" column is equal to "Peter".

    Rate this question:

  • 10. 

    How does a TRUNCATE TABLE statement differ from an unrestricted DELETE? Select all that apply.

    • A.

      Using TRUNCATE all the values in the table will be deleted but not the structure whereas as In Delete a particular row can be deleted but not the structure

    • B.

      Using TRUNCATE all the values in the table will be deleted and the structure as well but whereas as In Delete a particular row can be deleted but not the structure

    • C.

      Using TRUNCATE all the values in the table will be deleted but not the structure whereas as In Delete a particular row can be deleted and the structure as well

    • D.

      None of the Above

    Correct Answer
    A. Using TRUNCATE all the values in the table will be deleted but not the structure whereas as In Delete a particular row can be deleted but not the structure
    Explanation
    The correct answer is "Using TRUNCATE all the values in the table will be deleted but not the structure whereas as In Delete a particular row can be deleted but not the structure." This answer correctly explains the difference between a TRUNCATE TABLE statement and an unrestricted DELETE. TRUNCATE TABLE deletes all the values in the table but keeps the structure intact, while DELETE allows for the deletion of specific rows but does not affect the structure of the table.

    Rate this question:

  • 11. 

    Which of the following are parts of a SELECT statement? Choose all that apply. 

    • A.

      FROM

    • B.

      DEFINE

    • C.

      WHERE

    • D.

      DESELECT

    Correct Answer(s)
    A. FROM
    C. WHERE
    Explanation
    The SELECT statement is used in SQL to retrieve data from a database. It consists of various components, including the FROM clause and the WHERE clause. The FROM clause is used to specify the table or tables from which the data is being retrieved. The WHERE clause is used to specify the conditions that the data must meet in order to be included in the result set. Therefore, both FROM and WHERE are essential parts of a SELECT statement. On the other hand, DEFINE and DESELECT are not valid components of a SELECT statement, making them incorrect choices.

    Rate this question:

  • 12. 

    Which  is not used into SQL=,<>,> ,<,>=,<=,>>>  

    • A.

      All are used

    • B.

      Only >>> not used

    • C.

      Only

    • D.

      None

    Correct Answer
    B. Only >>> not used
    Explanation
    The correct answer is only >>> not used. This is because the >>> symbol is not a valid operator in SQL. SQL uses =, , >, =, and >> is not included in this list. Therefore, only >>> is not used in SQL.

    Rate this question:

  • 13. 

    Choose correct syntax to insert values into r4r_team table 

    • A.

      INSERT INTO r4r_team (id, username, exp) VALUES (1, ‘r4r01’, ‘2’);

    • B.

      INSERT IN r4r_team VALUES (1, ‘r4r01’, ‘2’);

    • C.

      INSERT INTO r4r_team (id, username, exp) VALUE (1, ‘r4r01’, ‘2’);

    • D.

      INSERT INTO table r4r_team (id, username, exp) VALUE (1, ‘r4r01’, ‘2’);

    Correct Answer
    A. INSERT INTO r4r_team (id, username, exp) VALUES (1, ‘r4r01’, ‘2’);
    Explanation
    The correct answer is "INSERT INTO r4r_team (id, username, exp) VALUES (1, ‘r4r01’, ‘2’)" because it follows the correct syntax for inserting values into the r4r_team table. The INSERT INTO statement is used to add data to a table, followed by the table name (r4r_team) and the column names (id, username, exp) in parentheses. The VALUES keyword is used to specify the values to be inserted, which are provided in the same order as the column names, also in parentheses. The values 1, 'r4r01', and '2' are inserted into the id, username, and exp columns respectively.

    Rate this question:

  • 14. 

    The following are clauses of the SELECT statement:1. WHERE 2. FROM 3. ORDER BY In which order should they appear in a query? 

    • A.

      1, 3, 2

    • B.

      2, 1, 3

    • C.

      2, 3, 1

    • D.

      The order of these clauses does not matter

    Correct Answer
    B. 2, 1, 3
    Explanation
    The correct answer is 2, 1, 3. In a SELECT statement, the FROM clause should appear first to specify the table or tables from which the data will be retrieved. The WHERE clause should come next to filter the data based on specified conditions. Finally, the ORDER BY clause should appear last to sort the retrieved data in a specified order.

    Rate this question:

  • 15. 

    Which single-row function could you use to return a specific portion of a character string? 

    • A.

      INSTR

    • B.

      SUBSTR

    • C.

      LPAD

    • D.

      LEAST

    Correct Answer
    B. SUBSTR
    Explanation
    SUBSTR is the correct answer because it is a single-row function that can be used to return a specific portion of a character string. It allows you to extract a substring from a larger string by specifying the starting position and the length of the substring you want to extract.

    Rate this question:

  • 16. 

    Which statement would change all occurrences of the string 'NESS' to the string 'SUN' in the DESCRIPTION column of the VENDOR table? 

    • A.

      SELECT TRANSLATE(description, 'NESS', 'SUN') FROM vendor

    • B.

      SELECT CONVERT(description, 'NESS', 'SUN') FROM vendor

    • C.

      SELECT EXTRACT(description, 'NESS', 'SUN') FROM vendor

    • D.

      SELECT REPLACE(description, 'NESS', 'SUN') FROM vendor

    Correct Answer
    D. SELECT REPLACE(description, 'NESS', 'SUN') FROM vendor
    Explanation
    The correct answer is SELECT REPLACE(description, 'NESS', 'SUN') FROM vendor. This statement uses the REPLACE function to replace all occurrences of the string 'NESS' with the string 'SUN' in the DESCRIPTION column of the VENDOR table.

    Rate this question:

  • 17. 

    Which statement successfully adds a new column ORDER_DATE to the table ORDERS?

    • A.

      ALTER TABLE ORDERS ADD COLUMN ORDER_DATE DATE;

    • B.

      ALTER TABLE ORDERS ADD ORDER_DATE (DATE);

    • C.

      ALTER TABLE ORDERS ADD ORDER_DATE DATE;

    • D.

      ALTER TABLE ORDERS NEW COLUMN ORDER_DATE TYPE DATE;

    Correct Answer
    C. ALTER TABLE ORDERS ADD ORDER_DATE DATE;
    Explanation
    This statement successfully adds a new column ORDER_DATE to the table ORDERS. It uses the correct syntax for adding a column to a table in SQL, which is "ALTER TABLE table_name ADD column_name data_type;". In this case, the table name is ORDERS, the column name is ORDER_DATE, and the data type is DATE.

    Rate this question:

  • 18. 

    You query the table with this commandSELECT nameFROM employeeWHERE name LIKE ‘_a%’; Which names are displayed? 

    • A.

      Names starting with “a”

    • B.

      Names starting with “a” or “A”

    • C.

      Names containing “a” as second character

    • D.

      Names containing “a” as any letter except the first

    Correct Answer
    C. Names containing “a” as second character
    Explanation
    The query is searching for names that start with any character followed by "a" and any number of characters after that. So the names displayed will be those that have "a" as the second character.

    Rate this question:

  • 19. 

    You issue the following query: SELECT empno, ename FROM emp WHERE empno = 7782 OR empno = 7876;         Which other operator can replace the OR condition in the WHERE clause

    • A.

      IN

    • B.

      BETWEEN.. AND..

    • C.

      LIKE

    • D.

    Correct Answer
    A. IN
    Explanation
    The IN operator can replace the OR condition in the WHERE clause. It allows you to specify multiple values in a single query, so instead of using multiple OR conditions, you can use the IN operator followed by a list of values to match against the empno column. This makes the query shorter and more concise.

    Rate this question:

  • 20. 

    ______________used to Create, Manage database objects in the database.

    • A.

      DDL

    • B.

      DML

    • C.

      DCL

    • D.

      DQL

    Correct Answer
    A. DDL
    Explanation
    DDL stands for Data Definition Language. It is used to create and manage database objects in the database. DDL statements are used to define the structure of the database, including creating tables, indexes, views, and other database objects. DDL statements are not used to manipulate or retrieve data, but rather to define the structure and organization of the database. Examples of DDL statements include CREATE, ALTER, and DROP.

    Rate this question:

  • 21. 

    Which Operators combine the results of two-component queries into a single result?

    • A.

      Character Operators

    • B.

      Comparison Operators

    • C.

      Set Operators

    • D.

      Miscellaneous Operators

    Correct Answer
    C. Set Operators
    Explanation
    Set operators combine the results of two-component queries into a single result. These operators allow you to perform operations such as union, intersection, and difference on sets of data. By using set operators, you can merge or compare the results of multiple queries, resulting in a consolidated and meaningful output. Therefore, the correct answer is Set Operators.

    Rate this question:

  • 22. 

    Which of the constraint can be defined at the table?

    • A.

      Check constraint

    • B.

      Primary Key

    • C.

      Unique

    • D.

      Default

    Correct Answer
    D. Default
    Explanation
    A default constraint can be defined at the table in a database. This constraint specifies a default value for a column if no value is provided during an insert operation. It ensures that the column always has a value, even if it is not explicitly provided. This can be useful for columns that have a commonly used default value, such as a date or a specific string.

    Rate this question:

  • 23. 

    Roll Back segment is not used in case of:

    • A.

      DCL

    • B.

      DDL

    • C.

      DQL

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    The roll back segment is not used in any of the mentioned cases: DCL (Data Control Language), DDL (Data Definition Language), and DQL (Data Query Language). DCL statements like GRANT and REVOKE do not require roll back segments as they do not modify data. DDL statements like CREATE and ALTER also do not use roll back segments as they only modify the structure of the database. DQL statements like SELECT do not require roll back segments as they only retrieve data and do not modify it. Therefore, the correct answer is "All of the above."

    Rate this question:

  • 24. 

    Which command will delete all data from a table and will not write to the rollback segment?

    • A.

      Drop

    • B.

      Delete

    • C.

      Truncate

    • D.

      Cascade

    Correct Answer
    C. Truncate
    Explanation
    The correct answer is "Truncate". The Truncate command is used to delete all data from a table without writing it to the rollback segment. It is a faster and more efficient way to delete all data compared to the Delete command. Truncate also resets the high water mark of the table, freeing up space in the table for future use.

    Rate this question:

  • 25. 

    How many columns are retrieved from this query: SELECT address1||','||address2||','||address2 "Address" FROM  employee;

    • A.

      1

    • B.

      2

    • C.

      3

    • D.

      4

    Correct Answer
    C. 3
    Explanation
    The given query retrieves three columns from the employee table. The SELECT statement concatenates the address1, address2, and address2 columns using the || operator and adds a comma between each value. The resulting column is aliased as "Address". Therefore, the query returns three columns: address1, address2, and the concatenated column "Address".

    Rate this question:

Quiz Review Timeline +

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

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jun 15, 2017
    Quiz Created by
    Abdul

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.