PostgreSQL: constraints, data types and privileges
No reviews yet
Intermediate
2 h
750 credits
First lab free
Important
You work with the database owner's account: it can do anything, including dropping a table. Write in transactions, check, then commit. Several queries in the workshop must fail: it is the database refusing, and that is the lesson. The validation checks that no real sale and no original product has disappeared. The sandbox lives for three hours.
Tip
When ALTER TABLE ADD CONSTRAINT fails, the database is doing you a favour: it tells you there are still rows that violate the rule. Find them with a SELECT on the opposite condition, sort them out, then set the rule again. And clean up with decisions, not with a formula: WHERE quantite <= 0 would also delete a real sale.
sql
constraints
check
unique
types
grant
PostgreSQL: constraints, data types and privileges · MonPremierLab