PostgreSQL Quiz – Test Your SQL Knowledge

Welcome to The Coding College, your ultimate hub for coding and programming tutorials! This PostgreSQL Quiz is designed to test your understanding of PostgreSQL concepts, from basic to advanced.

Challenge yourself with these quiz questions and measure your PostgreSQL expertise!

Quiz Instructions

  • Format: Multiple Choice Questions (MCQs) and True/False.
  • Topics Covered: Basic SQL, Joins, Functions, Data Manipulation, and Advanced Features.
  • Answer Key: Provided at the end for self-assessment.

Quiz Questions

Basic PostgreSQL Questions

  1. What is PostgreSQL?
    a. A programming language
    b. A relational database management system
    c. A web server
    d. An operating system
  2. Which command is used to create a new database in PostgreSQL?
    a. CREATE TABLE
    b. CREATE DATABASE
    c. NEW DATABASE
    d. INIT DATABASE
  3. What is the default port number for PostgreSQL?
    a. 3306
    b. 1521
    c. 5432
    d. 8080
  4. True or False: PostgreSQL supports JSON and JSONB data types.
  5. Which of the following is used to list all tables in a PostgreSQL database?
    a. SHOW TABLES
    b. \dt
    c. LIST TABLES
    d. DESCRIBE

Intermediate PostgreSQL Questions

  1. Which keyword is used to sort query results in ascending order?
    a. ASC
    b. ORDER
    c. SORT
    d. GROUP
  2. What is the difference between INNER JOIN and FULL JOIN?
    a. INNER JOIN returns only matching rows; FULL JOIN includes all rows.
    b. FULL JOIN returns only matching rows; INNER JOIN includes all rows.
    c. Both return the same result.
    d. None of the above.
  3. Which function is used to calculate the average value of a numeric column?
    a. SUM()
    b. AVG()
    c. COUNT()
    d. MAX()
  4. True or False: The LIMIT clause is used to restrict the number of rows returned by a query.
  5. What does the following query do? DELETE FROM employees WHERE department = 'HR'; a. Deletes all rows from the employees table.
    b. Deletes rows where the department is ‘HR’.
    c. Deletes the HR department from the database.
    d. None of the above.

Advanced PostgreSQL Questions

  1. What does VACUUM do in PostgreSQL?
    a. Deletes unused tables.
    b. Cleans up dead tuples and reclaims storage.
    c. Optimizes queries.
    d. Removes indexes.
  2. Which command is used to add a new column to an existing table?
    a. ALTER TABLE ADD COLUMN
    b. MODIFY TABLE ADD
    c. UPDATE TABLE ADD COLUMN
    d. INSERT COLUMN
  3. What is a CTE (Common Table Expression)?
    a. A temporary table used for one query.
    b. A permanent table stored in the database.
    c. A subquery that is reusable within a query.
    d. None of the above.
  4. True or False: PostgreSQL allows the creation of custom data types.
  5. Which function is used to concatenate strings in PostgreSQL?
    a. CONCAT()
    b. STRING()
    c. ||
    d. Both a and c

Answer Key

  1. b
  2. b
  3. c
  4. True
  5. b
  6. a
  7. a
  8. b
  9. True
  10. b
  11. b
  12. a
  13. c
  14. True
  15. d

How to Use This Quiz

  • For Beginners: Focus on the basic questions to solidify your understanding of PostgreSQL fundamentals.
  • For Intermediate Learners: Tackle the intermediate section to prepare for interviews and real-world scenarios.
  • For Advanced Users: Test your knowledge of advanced PostgreSQL features and commands.

Learn More on The Coding College

We prioritize Google’s E-E-A-T guidelines to ensure our content is reliable and beneficial to users. For more PostgreSQL tutorials, exercises, and guides, visit The Coding College.

Conclusion

Quizzes are an excellent way to assess your knowledge and identify areas for improvement. Use this PostgreSQL Quiz as a stepping stone to enhance your database skills.

Stay tuned to The Coding College for more engaging and informative content!

Leave a Comment