




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which PostgreSQL process is responsible for writing completed transaction log entries to the WAL files on disk? A) Logger B) WAL Writer C) Checkpointer D) Autovacuum Launcher Answer: B Explanation: The WAL Writer process periodically flushes WAL buffers to the WAL segment files, ensuring durability of committed transactions. Question 2. In PostgreSQL 10, which file contains configuration parameters that control server behavior such as shared buffers and logging? A) pg_hba.conf B) postgresql.conf C) pg_ident.conf D) recovery.conf Answer: B Explanation: postgresql.conf holds the majority of server configuration settings, including memory, connection, and logging options. Question 3. What does the acronym MVCC stand for, and what primary problem does it solve? A) Multi-Version Concurrency Control; it eliminates deadlocks.
B) Multi-Variable Column Compression; it reduces storage size. C) Multi-Version Concurrency Control; it allows concurrent reads and writes without locking. D) Multi-Value Check Constraint; it enforces data integrity. Answer: C Explanation: MVCC enables each transaction to see a consistent snapshot of the database, allowing concurrent access without traditional row-level locks. Question 4. Which isolation level in PostgreSQL guarantees that a transaction will see only data committed before it began, and never see phantom rows? A) Read Committed B) Repeatable Read C) Serializable D) Read Uncommitted Answer: C Explanation: Serializable isolation provides the strictest guarantees, preventing phantom reads and ensuring transaction results are as if executed serially. Question 5. Which PostgreSQL command creates a new database cluster (initializes the data directory)? A) createdb B) initdb C) pg_ctl init
Explanation: JSONB stores parsed binary JSON, allowing indexing (e.g., GIN) and faster query performance compared to plain JSON. Question 8. Which command is used to permanently remove dead tuples and optionally compact the table space? A) DELETE B) TRUNCATE C) VACUUM FULL D) REINDEX Answer: C Explanation: VACUUM FULL rewrites the entire table, reclaiming dead space and compacting storage, unlike regular VACUUM which only marks dead tuples. Question 9. What is the default authentication method for local connections on most PostgreSQL installations? A) trust B) md C) peer D) scram‑sha‑ 256 Answer: C Explanation: The “peer” method authenticates local Unix users by matching the operating system username to the PostgreSQL role name.
Question 10. Which system view provides information about currently executing queries and their state? A) pg_stat_user_tables B) pg_locks C) pg_stat_activity D) pg_stat_replication Answer: C Explanation: pg_stat_activity shows each backend’s current query, start time, and state (active, idle, etc.). Question 11. In PostgreSQL, what is the purpose of a tablespace? A) To enforce column constraints B) To group related tables logically C) To define a physical storage location for database objects D) To limit user connections Answer: C Explanation: A tablespace maps to a directory on disk where PostgreSQL stores the underlying files for tables, indexes, etc. Question 12. Which command will list all databases in a PostgreSQL cluster when using psql? A) \l B) \dt
Explanation: Square brackets alone are not valid; arrays must be expressed with ARRAY[…] or curly braces. Question 15. Which PostgreSQL background process is responsible for writing dirty buffers from shared memory to disk periodically? A) Checkpointer B) Background Writer C) WAL Writer D) Logger Answer: B Explanation: The Background Writer flushes dirty shared buffers to disk to reduce checkpoint latency. Question 16. What does the PostgreSQL configuration parameter “max_connections” control? A) Maximum concurrent client connections B) Maximum number of database clusters per server C) Maximum number of tables per database D) Maximum number of parallel workers for a query Answer: A Explanation: max_connections sets the limit on simultaneous client connections.
Question 17. Which SQL clause is used to filter rows after grouping has been performed? A) WHERE B) HAVING C) ORDER BY D) LIMIT Answer: B Explanation: HAVING applies conditions to aggregated groups, similar to WHERE but after GROUP BY. Question 18. Which PostgreSQL function returns the current transaction ID? A) txid_current() B) current_xid() C) pg_transaction_id() D) xid_current() Answer: A Explanation: txid_current() returns the XID of the current transaction. Question 19. In PostgreSQL, which type of join returns all rows from the left table and matching rows from the right table, inserting NULLs when no match exists? A) INNER JOIN B) LEFT OUTER JOIN
Explanation: The SERIAL pseudo‑type creates an integer column backed by a sequence and sets a default nextval. Question 22. What does the “log_destination” parameter in postgresql.conf specify? A) The network address for client connections B) The file path for data files C) Where server log output is sent (stderr, csvlog, syslog, eventlog) D) The location of the WAL files Answer: C Explanation: log_destination determines the logging target(s) for PostgreSQL’s log messages. Question 23. Which of the following statements about the pg_dump utility is true? A) It creates a physical copy of the data directory. B) It produces a logical backup that can be restored with pg_restore. C) It only backs up the schema, not the data. D) It requires the server to be stopped. Answer: B Explanation: pg_dump generates a logical SQL script (or custom format) that can be replayed with pg_restore.
Question 24. In PostgreSQL, which command is used to change the owner of a table to a different role? A) ALTER TABLE table_name OWNER TO new_owner; B) REASSIGN OWNED BY old_owner TO new_owner; C) GRANT ALL ON table_name TO new_owner; D) SET ROLE new_owner; Answer: A Explanation: ALTER TABLE … OWNER TO changes the table’s owner. Question 25. Which JSON operator extracts a JSON object field as JSON, preserving its type? A) - > B) - >> C) #> D) #>> Answer: A Explanation: The - > operator returns the field as JSON, while - >> returns it as text. Question 26. What is the effect of setting “shared_buffers” to a high value? A) Increases the number of allowed connections. B) Allocates more memory for PostgreSQL’s buffer cache, potentially improving read performance.
Explanation: pg_stat_user_tables tracks per‑table I/O and modification statistics. Question 29. In PostgreSQL, which clause is used to combine the result sets of two SELECT statements while removing duplicate rows? A) UNION ALL B) INTERSECT C) EXCEPT D) UNION Answer: D Explanation: UNION merges two result sets and eliminates duplicates; UNION ALL keeps all rows. Question 30. What does the “autovacuum” daemon do automatically? A) Rewrites tables to compress them. B) Performs VACUUM and ANALYZE on tables based on activity thresholds. C) Moves tables to different tablespaces. D) Generates automatic backups. Answer: B Explanation: Autovacuum triggers VACUUM and ANALYZE to reclaim space and update statistics. Question 31. Which of the following is a valid way to start PostgreSQL as a background service on Linux using pg_ctl?
A) pg_ctl start - D /var/lib/pgsql/data - l logfile B) pg_ctl run - D /var/lib/pgsql/data C) pg_ctl launch - D /var/lib/pgsql/data D) pg_ctl begin - D /var/lib/pgsql/data Answer: A Explanation: pg_ctl start launches the server; - l specifies the log file. Question 32. Which of the following PostgreSQL data types can store a fixed‑length collection of elements of the same type? A) ARRAY B) JSON C) HSTORE D) TEXT[] Answer: A (ARRAY is the generic type; TEXT[] is a specific instance) Explanation: ARRAY is the fundamental type for fixed‑length collections; specific element types are declared as element_type[]. Question 33. Which command grants SELECT privilege on all tables in schema “public” to role “reporter”? A) GRANT SELECT ON ALL TABLES IN SCHEMA public TO reporter; B) GRANT SELECT ON SCHEMA public TO reporter; C) GRANT SELECT ON DATABASE mydb TO reporter;
Question 36. What is the default port number on which PostgreSQL listens for client connections? A) 1521 B) 5432 C) 3306 D) 8080 Answer: B Explanation: Port 5432 is the standard PostgreSQL listening port. Question 37. Which of the following statements about the “EXPLAIN ANALYZE” command is true? A) It only shows the estimated cost, not actual execution time. B) It executes the query and displays actual run times along with the plan. C) It modifies the query plan to be more efficient. D) It disables indexes for the duration of the query. Answer: B Explanation: EXPLAIN ANALYZE runs the query and reports both the planned and actual execution statistics. Question 38. Which PostgreSQL feature allows you to store key‑value pairs within a single column? A) ARRAY
Answer: C Explanation: HSTORE stores sets of (key, value) pairs as text, suitable for flexible schemas. Question 39. Which command creates a new role “analyst” that can login but cannot create databases or other roles? A) CREATE ROLE analyst WITH LOGIN; B) CREATE ROLE analyst NOLOGIN CREATEDB; C) CREATE ROLE analyst WITH LOGIN NOCREATEDB NOCREATEROLE; D) CREATE ROLE analyst WITH LOGIN SUPERUSER; Answer: C Explanation: LOGIN allows connection; NOCREATEDB and NOCREATEROLE restrict creation privileges. Question 40. What does the “pg_basebackup” utility primarily provide? A) Logical dump of schema and data. B) Physical base backup of an entire cluster for PITR. C) Incremental backup of changed WAL files only. D) Automated vacuum statistics.
Question 43. Which of the following is true about PostgreSQL’s “inherit” attribute for roles? A) It allows a role to inherit privileges from roles it is a member of. B) It prevents a role from being granted any privileges. C) It makes the role a superuser automatically. D) It disables password authentication for the role. Answer: A Explanation: With INHERIT (default), a role automatically gains privileges of roles it belongs to. Question 44. Which of these statements about GIN indexes is correct? A) They are optimal for equality searches on scalar columns. B) They are used primarily for full‑text search and array containment. C) They cannot be used with JSONB data. D) They are always faster than B‑Tree indexes for any query. Answer: B Explanation: GIN indexes excel at indexing composite values like arrays, JSONB, and full‑text search. Question 45. In PostgreSQL, which clause is used to limit the number of rows returned by a query? A) TOP
D) BOTH B AND C (LIMIT or FETCH FIRST) Answer: D Explanation: PostgreSQL supports both LIMIT and the SQL‑standard FETCH FIRST n ROWS ONLY. Question 46. What is the purpose of the “pg_hba.conf” entry type “hostssl”? A) It allows only SSL‑encrypted connections from the specified hosts. B) It permits connections from any host without authentication. C) It defines a host‑based firewall rule. D) It forces password authentication over plain TCP. Answer: A Explanation: hostssl restricts connections to those that use SSL/TLS. Question 47. Which of the following statements about the “serializable” isolation level in PostgreSQL is accurate? A) It uses predicate locking to prevent anomalies. B) It is implemented using MVCC snapshots only. C) It allows dirty reads. D) It is the default isolation level. Answer: A