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.
Think about what happens if someone reads your diary without permission.
Database security protects sensitive information from unauthorized access or changes, just like locking your diary keeps your secrets safe.
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?
SELECT * FROM employees;
Think about what happens when a user tries to access a table without permission.
PostgreSQL returns a permission denied error when a user lacks SELECT rights on a table.
You want to allow a user named report_user to read data from the sales table only. Which SQL command correctly grants this permission?
PostgreSQL uses the GRANT statement with SELECT privilege for read access.
The correct syntax to grant read access is GRANT SELECT ON TABLE sales TO report_user;. Other options are invalid SQL or incorrect syntax.
You have a table customers with sensitive columns like credit_card_number. What is the best way to protect this data in PostgreSQL?
Think about protecting data both by encryption and access control.
Encrypting sensitive data and controlling access with roles is a strong security practice. Other options either expose data or remove it unnecessarily.
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;
Check if the user belongs to other roles or has extra permissions.
Granting SELECT alone does not allow UPDATE. If the user can update, they likely have other roles or permissions granting that right.