PostgreSQL Database Quiz Questions

Course Name:PostgreSQL
Chapter Name:Chapter 3 - Database Tables, Columns and Rows
Lesson Content Link:ROWs and COLUMNs
Current Quiz Count:30
Progress
0%
Q1
True / False

In PostgreSQL, each row in a table must have a unique identifier.

Q2
True / False

In PostgreSQL, the data type of a column can be defined when creating the table.

Q3
True / False

In PostgreSQL, the NOT NULL constraint ensures that a column cannot have NULL values.

Q4
True / False

PostgreSQL allows you to rename a column in an existing table using the ALTER TABLE statement.

Q5
True / False

In PostgreSQL, the UNIQUE constraint allows duplicate values in the specified column.

Q6
True / False

In PostgreSQL, you can define default values for columns in a table.

Q7
True / False

PostgreSQL supports array data types, allowing a column to store multiple values in a single row.

Q8
True / False

In PostgreSQL, the ROW_NUMBER() window function can be used to assign unique sequential integer values to rows within a partition of a result set.

Q9
True / False

PostgreSQL does not support the ability to store JSON data in table columns.

Q10
True / False

In PostgreSQL, the GENERATED ALWAYS AS IDENTITY clause can be used to create auto-incrementing columns.

Q11
Single Choice

Which MySQL keyword is used to retrieve all rows from a specific column in a table?

Q12
Single Choice

How do you return only distinct values in a specific column from a MySQL table?

Q13
Single Choice

What does the following SQL query do?

SQL Code
SELECT column1, column2 FROM table_name;
Q14
Single Choice

Which MySQL clause would you use to filter rows that match specific criteria in a column?

Q15
Single Choice

What will the following SQL query return?

SQL Code
SELECT COUNT(*) FROM employees WHERE department_id = 5;
Q16
Single Choice

How can you add a new column email to an existing MySQL table users?

SQL Code
________ users ADD COLUMN email VARCHAR(255);
Q17
Single Choice

Which SQL statement will select all rows where the last_name column has a NULL value?

SQL Code
SELECT * FROM customers WHERE last_name ____ NULL;
Q18
Single Choice

What will the following query do if the users table contains 10 rows?

SQL Code
DELETE FROM users WHERE id > 5;
Q19
Single Choice

Given the following SQL query, what does the keyword ROW_NUMBER() do?

SQL Code
SELECT *, ROW_NUMBER() OVER (ORDER BY salary DESC) AS rank FROM employees;
Q20
Single Choice

Which MySQL statement will update multiple columns in all rows where status is 'active'?

SQL Code
UPDATE orders SET quantity = quantity + 1, price = price * 1.1 WHERE status = 'active';
Q21
Multiple Choice

Which SQL command would you use to retrieve specific columns from a PostgreSQL table?

SQL Code
SELECT first_name, last_name, email
FROM employees
WHERE department = 'HR';
Q22
Multiple Choice

Which SQL statement correctly updates a specific row in a PostgreSQL table?

SQL Code
UPDATE orders
SET status = 'shipped'
WHERE order_id = 12345;
Q23
Multiple Choice

Which SQL command would you use to add a new row to a PostgreSQL table?

SQL Code
INSERT INTO customers (first_name, last_name, email)
VALUES ('Jane', 'Doe', 'jane.doe@example.com');
Q24
Multiple Choice

Which SQL query retrieves the total number of rows in a PostgreSQL table?

SQL Code
SELECT COUNT(*)
FROM products;
Q25
Multiple Choice

Which SQL command is used to modify a column's data type in a PostgreSQL table?

SQL Code
ALTER TABLE orders
ALTER COLUMN order_date TYPE TIMESTAMP;
Q26
Multiple Choice

Which SQL command removes specific rows from a PostgreSQL table based on a condition?

SQL Code
DELETE FROM employees
WHERE department = 'Sales';
Q27
Multiple Choice

Which SQL query is used to retrieve distinct values from a column in a PostgreSQL table?

SQL Code
SELECT DISTINCT department
FROM employees;
Q28
Multiple Choice

Which SQL command adds a check constraint to ensure that a column's value is positive in PostgreSQL?

SQL Code
ALTER TABLE products
ADD CONSTRAINT chk_price
CHECK (price > 0);
Q29
Multiple Choice

Which SQL query correctly retrieves rows that have NULL values in a specific column in PostgreSQL?

SQL Code
SELECT * FROM orders
WHERE delivery_date IS NULL;
Q30
Multiple Choice

Which SQL command is used to rename a column in a PostgreSQL table?

SQL Code
ALTER TABLE customers
RENAME COLUMN full_name TO name;