CodeBlanks Logo Icon CodeBlanks

Summary - Security and backup

Build a secure setup with GRANT and prepared statements.

Summary - Security and backup

Security and backup: PREPARE against SQL injection, GRANT/REVOKE for privileges, COPY TO for backup, COPY FROM for recovery. Least privilege and regular backups are core principles.

-- PREPARE -> GRANT -> COPY TO -> COPY FROM
-- en az yetki, düzenli yedek

Security and backup go hand in hand.

Practice Summary - Security and backup

Summary task: give the reader role read access on orders.

Starter code

query.sql
-- summary security
GRANT

Sample solution

query.sql
GRANT SELECT ON orders TO reader;

Expected output

GRANT

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Read permission

Question
GRANT SELECT ON orders TO ____
Answer
GRANT SELECT ON orders TO reader

Explanation: Read access is granted with GRANT SELECT; the reader role can only run SELECT.

2 What is used against SQL injection?

  • INDEX
  • TRIGGER
  • PREPARE Correct answer
  • VIEW

Explanation: PREPARE is used against SQL injection.

3 Summary - Security and backup: match the terms

Term Meaning
PREPARE prepare
GRANT grant
COPY TO backup
PITR point-in-time

All lessons in Expert