0
0
PostgreSQLquery~20 mins

Why database security matters in PostgreSQL - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Database Security Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
Why is database security important?

Imagine you have a diary where you write your secrets. Why should you keep it locked and safe?

Choose the best reason why database security is important.

ATo prevent unauthorized people from reading or changing the data.
BTo make the database run faster.
CTo allow everyone to access the data easily.
DTo reduce the size of the database files.
Attempts:
2 left
💡 Hint

Think about what happens if someone reads your diary without permission.

query_result
intermediate
1:30remaining
Identify the effect of a missing user permission

Given a PostgreSQL database with a table employees, a user tries to run this query:

SELECT * FROM employees;

The user does not have SELECT permission on the table. What error message will PostgreSQL return?

PostgreSQL
SELECT * FROM employees;
AERROR: syntax error at or near "*"
BERROR: permission denied for table employees
CERROR: column "*" does not exist
DERROR: relation "employees" does not exist
Attempts:
2 left
💡 Hint

Think about what happens when a user tries to access a table without permission.

📝 Syntax
advanced
1:30remaining
Find the correct SQL to grant read access

You want to allow a user named report_user to read data from the sales table only. Which SQL command correctly grants this permission?

AGRANT SELECT * FROM sales TO report_user;
BGRANT READ ON sales TO report_user;
CGRANT SELECT ON TABLE sales TO report_user;
DALLOW SELECT ON sales FOR report_user;
Attempts:
2 left
💡 Hint

PostgreSQL uses the GRANT statement with SELECT privilege for read access.

optimization
advanced
2:00remaining
Best practice to secure sensitive columns

You have a table customers with sensitive columns like credit_card_number. What is the best way to protect this data in PostgreSQL?

AAllow all users to access the table but log all queries.
BStore the data in plain text but hide the table from users.
CDelete the sensitive columns to avoid risk.
DEncrypt the sensitive columns and restrict access using roles.
Attempts:
2 left
💡 Hint

Think about protecting data both by encryption and access control.

🔧 Debug
expert
2:30remaining
Identify the security risk in this PostgreSQL setup

A database admin created a user readonly and granted SELECT on all tables. However, the user can still update data. What is the most likely cause?

Consider this setup:

CREATE USER readonly WITH PASSWORD 'pass';
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonly;
AThe user has additional roles or permissions granting UPDATE rights.
BThe GRANT SELECT command also allows UPDATE implicitly.
CThe password is too weak, allowing unauthorized access.
DPostgreSQL does not support restricting UPDATE permissions.
Attempts:
2 left
💡 Hint

Check if the user belongs to other roles or has extra permissions.