PostgreSQL Database Quiz Questions

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

SQL stands for Structured Query Language.

Q2
True / False

SQL is a programming language designed for querying and modifying databases.

Q3
True / False

SQL cannot be used to delete data from a database.

Q4
True / False

SQL commands are divided into categories such as DDL, DML, DCL, and TCL.

Q5
True / False

In PostgreSQL, SQL is used to create and manage tables.

Q6
True / False

SQL is case-sensitive in PostgreSQL, meaning that SELECT and select are treated differently.

Q7
True / False

SQL in PostgreSQL can be used to perform complex transactions that include multiple statements executed as a single unit of work.

Q8
True / False

SQL functions in PostgreSQL can include control-of-flow statements such as IF and LOOP.

Q9
True / False

SQL in PostgreSQL does not support recursive queries.

Q10
True / False

In PostgreSQL, the EXPLAIN statement in SQL is used to display the execution plan of a query.

Q11
Single Choice

Which SQL command is used to retrieve data from a MySQL database?

Q12
Single Choice

What does the DISTINCT keyword do in a MySQL SELECT statement?

Q13
Single Choice

Which of the following SQL statements is used to update data in a MySQL table?

Q14
Single Choice

Which of the following SQL queries will return the total number of rows in the employees table?

Q15
Single Choice

How do you select all records from the customers table where the city column is either 'New York' or 'Los Angeles'?

Q16
Single Choice

What is the correct SQL syntax to create a MySQL table named orders with an id column that auto-increments?

Q17
Single Choice

Which SQL query would you use to find the names of employees who have the highest salary in the employees table?

Q18
Single Choice

What is the correct SQL query to return the average salary of all employees grouped by department in the employees table?

Q19
Single Choice

How do you modify a MySQL table to add a new column age with data type INT to an existing customers table?

Q20
Single Choice

You need to retrieve the second highest salary from the employees table in MySQL. Which SQL query would you use?

Q21
Multiple Choice

Which SQL query retrieves all columns for rows where the column 'status' is 'active' in a PostgreSQL table?

SQL Code
SELECT *
FROM employees
WHERE status = 'active';
Q22
Multiple Choice

Which SQL command adds a new column 'date_of_birth' to an existing PostgreSQL table 'customers'?

SQL Code
ALTER TABLE customers
ADD COLUMN date_of_birth DATE;
Q23
Multiple Choice

Which SQL query correctly updates a row's column value in a PostgreSQL table?

SQL Code
UPDATE orders
SET delivery_date = '2024-08-01'
WHERE order_id = 1001;
Q24
Multiple Choice

Which SQL command is used to remove a specific row from a PostgreSQL table?

SQL Code
DELETE FROM customers
WHERE customer_id = 123;
Q25
Multiple Choice

Which SQL query retrieves only distinct values from the 'department' column in a PostgreSQL table?

SQL Code
SELECT DISTINCT department
FROM employees;
Q26
Multiple Choice

Which SQL command adds a NOT NULL constraint to an existing column in a PostgreSQL table?

SQL Code
ALTER TABLE employees
ALTER COLUMN email SET NOT NULL;
Q27
Multiple Choice

Which SQL command renames an existing column in a PostgreSQL table?

SQL Code
ALTER TABLE customers
RENAME COLUMN full_name TO name;
Q28
Multiple Choice

Which SQL query retrieves rows where a column has NULL values in PostgreSQL?

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

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

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

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

SQL Code
SELECT COUNT(*)
FROM products;