MVCC allows each transaction to see a snapshot of data, preventing readers from blocking writers and vice versa.
Incorrect! Try again.
3What is the default TCP port that PostgreSQL listens on?
A.8080
B.3306
C.5432
D.1521
Correct Answer: 5432
Explanation:
Port 5432 is the standard default port assigned to PostgreSQL.
Incorrect! Try again.
4What is the name of the interactive terminal-based command-line tool for PostgreSQL?
A.sqlcmd
B.pgAdmin
C.psql
D.pg_terminal
Correct Answer: psql
Explanation:
psql is the primary terminal-based front-end to PostgreSQL allowing users to type queries interactively.
Incorrect! Try again.
5Which configuration file is primarily responsible for controlling client authentication in PostgreSQL?
A.config.json
B.pg_hba.conf
C.postgresql.conf
D.pg_ident.conf
Correct Answer: pg_hba.conf
Explanation:
pg_hba.conf (Host Based Authentication) controls which hosts are allowed to connect, how clients are authenticated, and which PostgreSQL user names they can use.
Incorrect! Try again.
6What is the default superuser account created during PostgreSQL installation?
A.sa
B.postgres
C.admin
D.root
Correct Answer: postgres
Explanation:
The default operating system user and database superuser created by the PostgreSQL installer is named 'postgres'.
Incorrect! Try again.
7Which command inside the psql interface is used to list all databases?
A.\l
B.SHOW DATABASES;
C.\list
D.Both A and B
Correct Answer: Both A and B
Explanation:
In psql, \l is a shortcut for \list; both commands display the list of databases on the server.
Incorrect! Try again.
8Which data type in PostgreSQL is best suited for storing JSON data with indexing capabilities?
A.JSONB
B.VARCHAR
C.TEXT
D.JSON
Correct Answer: JSONB
Explanation:
JSONB stores data in a decomposed binary format, which is slower to input but faster to process and supports indexing.
Incorrect! Try again.
9Which SQL statement is used to create a new database in PostgreSQL?
A.CREATE DATABASE name;
B.NEW DATABASE name;
C.MAKE DATABASE name;
D.INIT DATABASE name;
Correct Answer: CREATE DATABASE name;
Explanation:
CREATE DATABASE is the standard SQL command to instantiate a new database container.
Incorrect! Try again.
10What does the acronym WAL stand for in the context of PostgreSQL architecture?
A.Wide-Area Latency
B.Web Application Layer
C.Write-Ahead Logging
D.Write-After Log
Correct Answer: Write-Ahead Logging
Explanation:
WAL (Write-Ahead Logging) is a standard method for ensuring data integrity by logging changes before writing them to the main database files.
Incorrect! Try again.
11Which command allows you to connect to a specific database from within the psql prompt?
A.\connect dbname
B.\use dbname
C.\c dbname
D.Both A and B
Correct Answer: Both A and B
Explanation:
\c is the shorthand for \connect; both are used to switch the current database connection in psql.
Incorrect! Try again.
12To remove a table and all its data from the database, which command is used?
A.DELETE TABLE
B.ERASE TABLE
C.DROP TABLE
D.REMOVE TABLE
Correct Answer: DROP TABLE
Explanation:
DROP TABLE removes the table definition and all associated data permanently.
Incorrect! Try again.
13Which PostgreSQL data type is an auto-incrementing integer typically used for primary keys?
A.NUMERIC
B.INT
C.AUTO_INT
D.SERIAL
Correct Answer: SERIAL
Explanation:
The SERIAL pseudo-type automatically creates a sequence and assigns the next value to the column, useful for IDs.
Incorrect! Try again.
14What is the purpose of the 'TRUNCATE' command?
A.To delete specific rows based on a condition
B.To drop the table structure
C.To minify the database size
D.To delete all rows quickly without logging individual row deletions
Correct Answer: To delete all rows quickly without logging individual row deletions
Explanation:
TRUNCATE empties a table much faster than DELETE because it does not scan the table or vacuum it, but it cannot use a WHERE clause.
Incorrect! Try again.
15Which constraint ensures that a column cannot contain NULL values?
A.PRIMARY KEY
B.NOT NULL
C.UNIQUE
D.CHECK
Correct Answer: NOT NULL
Explanation:
The NOT NULL constraint strictly enforces that a column must have a value for every row.
Incorrect! Try again.
16How do you rename an existing table 'users' to 'customers' in PostgreSQL?
A.MODIFY TABLE users RENAME customers;
B.UPDATE TABLE users SET NAME = customers;
C.ALTER TABLE users RENAME TO customers;
D.RENAME TABLE users TO customers;
Correct Answer: ALTER TABLE users RENAME TO customers;
Explanation:
The ALTER TABLE command combined with RENAME TO is the syntax used to change a table's name.
Incorrect! Try again.
17Which operator is used for pattern matching with wildcards in a WHERE clause?
A.MATCH
B.LIKE
C.SAME
D.=
Correct Answer: LIKE
Explanation:
The LIKE operator is used to search for a specified pattern in a column.
Incorrect! Try again.
18In the context of the LIKE operator, what does the '%' wildcard represent?
A.A NULL value
B.Zero or more characters
C.A numeric digit
D.Exactly one character
Correct Answer: Zero or more characters
Explanation:
The percent sign (%) represents zero, one, or multiple characters in a string comparison.
Incorrect! Try again.
19Which SQL clause is used to filter records that meet a specified condition?
A.ORDER BY
B.HAVING
C.GROUP BY
D.WHERE
Correct Answer: WHERE
Explanation:
The WHERE clause is used to extract only those records that fulfill a specified condition.
Incorrect! Try again.
20What is the correct syntax to insert a new record into the 'students' table?
A.ADD TO students VALUES (1, 'John');
B.INSERT students SET id=1, name='John';
C.INSERT INTO students (id, name) VALUES (1, 'John');
D.UPDATE students ADD (1, 'John');
Correct Answer: INSERT INTO students (id, name) VALUES (1, 'John');
Explanation:
Standard SQL syntax for adding data is INSERT INTO table_name (columns) VALUES (values).
Incorrect! Try again.
21How can you retrieve all columns from the 'employees' table?
A.FETCH employees;
B.SELECT * FROM employees;
C.SELECT ALL FROM employees;
D.GET * FROM employees;
Correct Answer: SELECT * FROM employees;
Explanation:
The asterisk (*) is a wildcard character in SQL meaning 'all columns'.
Incorrect! Try again.
22Which clause allows you to limit the number of rows returned by a query?
A.STOP
B.TOP
C.LIMIT
D.ROWNUM
Correct Answer: LIMIT
Explanation:
PostgreSQL uses the LIMIT clause to specify the maximum number of records to return.
Incorrect! Try again.
23Which command allows you to skip a specific number of rows before returning the result set?
A.NEXT
B.SKIP
C.OFFSET
D.JUMP
Correct Answer: OFFSET
Explanation:
The OFFSET clause is used to skip the specified number of rows before beginning to return rows.
Incorrect! Try again.
24What is the correct syntax to update the email of a user with id 5?
A.SET users.email = 'new@test.com' WHERE id = 5;
B.MODIFY users SET email = 'new@test.com' WHERE id = 5;
C.UPDATE users SET email = 'new@test.com' WHERE id = 5;
D.CHANGE users email = 'new@test.com' WHERE id = 5;
Correct Answer: UPDATE users SET email = 'new@test.com' WHERE id = 5;
Explanation:
The UPDATE statement uses the SET clause to modify values and WHERE to identify rows.
Incorrect! Try again.
25What happens if you run a DELETE FROM table_name command without a WHERE clause?
A.It deletes the table structure.
B.It throws a syntax error.
C.It deletes the first row.
D.It deletes all rows in the table.
Correct Answer: It deletes all rows in the table.
Explanation:
Without a WHERE clause, the DELETE command applies to all rows in the table, effectively clearing the data.
Incorrect! Try again.
26Which keyword is used to return data immediately after an INSERT, UPDATE, or DELETE operation in PostgreSQL?
A.BACK
B.RETURNING
C.RETURN
D.OUTPUT
Correct Answer: RETURNING
Explanation:
The RETURNING clause causes the command to return the value of modified rows, often used to get the ID of a newly inserted row.
Incorrect! Try again.
27Which PostgreSQL data type stores both date and time?
A.TIMESTAMP
B.DATE
C.DATETIME
D.TIME
Correct Answer: TIMESTAMP
Explanation:
TIMESTAMP stores both date and time. PostgreSQL also supports TIMESTAMP WITH TIME ZONE.
Incorrect! Try again.
28Which command is used to modify the structure of an existing table, such as adding a column?
A.MODIFY TABLE
B.ALTER TABLE
C.UPDATE TABLE
D.CHANGE TABLE
Correct Answer: ALTER TABLE
Explanation:
ALTER TABLE is the DDL command used to add, drop, or modify columns in an existing table.
Incorrect! Try again.
29To ensure a column's value is unique across the entire table, which constraint should be used?
A.UNIQUE
B.DISTINCT
C.SINGLE
D.PRIMARY
Correct Answer: UNIQUE
Explanation:
The UNIQUE constraint ensures that all values in a column are different.
Incorrect! Try again.
30Which operator is used to combine string values in PostgreSQL?
A.+
B.&
C.||
D.CONCAT()
Correct Answer: ||
Explanation:
The double pipe (||) is the standard concatenation operator in PostgreSQL, though the CONCAT function also exists.
Incorrect! Try again.
31How do you sort the result set in descending order?
A.SORT BY column_name DESC
B.ORDER BY column_name DESC
C.GROUP BY column_name DESC
D.ORDER BY column_name ASC
Correct Answer: ORDER BY column_name DESC
Explanation:
The ORDER BY clause with the DESC keyword sorts the records in descending order.
Incorrect! Try again.
32Which function is used to count the number of rows in a selection?
A.TOTAL()
B.SUM()
C.COUNT()
D.ADD()
Correct Answer: COUNT()
Explanation:
COUNT() returns the number of rows that match a specified criterion.
Incorrect! Try again.
33What is the purpose of the DISTINCT keyword in a SELECT statement?
A.To limit results
B.To filter null values
C.To remove duplicate values from the result set
D.To sort results
Correct Answer: To remove duplicate values from the result set
Explanation:
SELECT DISTINCT returns only distinct (different) values.
Incorrect! Try again.
34Which of the following is a correct command to add a new column 'age' of type integer to table 'people'?
A.UPDATE TABLE people ADD age INTEGER;
B.INSERT COLUMN age INTEGER INTO people;
C.ALTER people ADD age INTEGER;
D.ALTER TABLE people ADD COLUMN age INTEGER;
Correct Answer: ALTER TABLE people ADD COLUMN age INTEGER;
Explanation:
The correct syntax is ALTER TABLE table_name ADD COLUMN column_name data_type.
Incorrect! Try again.
35What does the psql command '\d table_name' do?
A.Downloads the table
B.Duplicates the table
C.Describes the table structure
D.Deletes the table
Correct Answer: Describes the table structure
Explanation:
\d stands for describe; it shows columns, types, and modifiers of the specified table.
Incorrect! Try again.
36Which logical operator is used to display a record if any of the conditions separated by it are true?
A.XOR
B.AND
C.OR
D.NOT
Correct Answer: OR
Explanation:
The OR operator displays a record if any of the conditions listed are true.
Incorrect! Try again.
37How do you check for a NULL value in a WHERE clause?
A.IS NULL
B.== NULL
C.= NULL
D.EQUALS NULL
Correct Answer: IS NULL
Explanation:
You cannot compare NULL with '=', you must use 'IS NULL' or 'IS NOT NULL'.
Incorrect! Try again.
38Which PostgreSQL tool is a popular open-source GUI for database management?
A.pgAdmin
B.Workbench
C.Compass
D.phpMyAdmin
Correct Answer: pgAdmin
Explanation:
pgAdmin is the most popular and feature-rich Open Source administration and development platform for PostgreSQL.
Incorrect! Try again.
39What does the PRIMARY KEY constraint imply?
A.Both UNIQUE and NOT NULL
B.Just an index
C.NOT NULL only
D.UNIQUE only
Correct Answer: Both UNIQUE and NOT NULL
Explanation:
A Primary Key uniquely identifies each record, so it cannot contain duplicates (UNIQUE) and cannot contain NULLs.
Incorrect! Try again.
40Which command allows you to quit the psql terminal?
A.logout
B.exit
C.\q
D.quit
Correct Answer: \q
Explanation:
\q is the specific command in psql to quit/exit the interactive shell.
Incorrect! Try again.
41Which clause is used to filter groups of rows created by GROUP BY?
A.FILTER
B.LIMIT
C.WHERE
D.HAVING
Correct Answer: HAVING
Explanation:
The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions.
Incorrect! Try again.
42Which statement is used to delete an entire database?
A.DROP DATABASE name;
B.REMOVE DATABASE name;
C.TRUNCATE DATABASE name;
D.DELETE DATABASE name;
Correct Answer: DROP DATABASE name;
Explanation:
DROP DATABASE is the command to permanently remove a database and all its contents.
Incorrect! Try again.
43What is the purpose of the 'IN' operator?
A.To specify a range
B.To specify multiple possible values for a column
C.To search text patterns
D.To check for NULL
Correct Answer: To specify multiple possible values for a column
Explanation:
The IN operator allows you to specify multiple values in a WHERE clause (shorthand for multiple OR conditions).
Incorrect! Try again.
44Which data type would be most appropriate for a True/False value?
A.INT
B.BINARY
C.BOOLEAN
D.VARCHAR(1)
Correct Answer: BOOLEAN
Explanation:
PostgreSQL supports a native BOOLEAN data type for storing true, false, or null states.
Incorrect! Try again.
45What does the BETWEEN operator select?
A.Values within a given range
B.Values that match a list
C.Values that are distinct
D.Values that are null
Correct Answer: Values within a given range
Explanation:
The BETWEEN operator selects values within a given range strictly. The values can be numbers, text, or dates.
Incorrect! Try again.
46To create a foreign key, which table is modified?
A.The child table
B.The parent table
C.Both tables
D.The system table
Correct Answer: The child table
Explanation:
The Foreign Key constraint is defined on the child table to reference the Primary Key in the parent table.
Incorrect! Try again.
47Which command is used to remove a specific column from a table?
A.ALTER TABLE ... DROP COLUMN ...
B.ALTER TABLE ... REMOVE COLUMN ...
C.ALTER TABLE ... DELETE COLUMN ...
D.DROP COLUMN ... FROM ...
Correct Answer: ALTER TABLE ... DROP COLUMN ...
Explanation:
The correct syntax to delete a column is using ALTER TABLE combined with DROP COLUMN.
Incorrect! Try again.
48Which basic SQL command is NOT part of CRUD operations?
A.CREATE
B.INSERT
C.UPDATE
D.SELECT
Correct Answer: CREATE
Explanation:
CRUD stands for Create (INSERT), Read (SELECT), Update (UPDATE), Delete (DELETE). CREATE is a DDL (Data Definition Language) command, not a DML (Data Manipulation) operation representing the 'C' in CRUD data manipulation.
Incorrect! Try again.
49What is the default sort order if ASC or DESC is not specified in ORDER BY?
A.Descending
B.Random
C.Ascending
D.Insertion Order
Correct Answer: Ascending
Explanation:
By default, SQL sorts results in Ascending (ASC) order.
Incorrect! Try again.
50Which character is used to denote a parameter/variable placeholder in a prepared statement in psql (e.g., $1, $2)?
A.@
B.$
C.:
D.?
Correct Answer: $
Explanation:
PostgreSQL uses positional parameters indicated by $ followed by a number (e.g., $1, $2) in prepared statements/queries.
Incorrect! Try again.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill.
The rest comes out of a student's own pocket: the domain, the storage,
and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it.
What it pays for →