SELECT * FROM app.customers;SELECT app.full_name(c) FROM app.customers c;
Form
Meaning
schema.table
Disambiguates across schemas
db.schema.table
Only allowed for current DB
"Schema".table
Quote case-sensitive identifiers
8. Renaming Schema
ALTER SCHEMA reports RENAME TO reporting;
Requirement
Detail
Caller
Schema owner or superuser
Side effect
References by qualified name break
9. Changing Schema Owner
ALTER SCHEMA app OWNER TO new_owner;REASSIGN OWNED BY old_owner TO new_owner; -- all objects
Command
Scope
ALTER SCHEMA
Schema only
REASSIGN OWNED
Schema + all owned tables/funcs
DROP OWNED BY
Drop all objects of role
10. Dropping Schema
DROP SCHEMA staging; -- fails if not emptyDROP SCHEMA IF EXISTS staging;
Mode
Behavior
default (RESTRICT)
Errors if objects exist
CASCADE
Drops dependent objects
11. Dropping Schema Cascade
DROP SCHEMA staging CASCADE;
Warning: CASCADE will silently drop foreign keys, views, sequences, and any object referencing the schema. Inspect dependencies first with \d+ and pg_depend.
Pre-drop Check
Query
Tables
SELECT tablename FROM pg_tables WHERE schemaname='staging';
Dependents
SELECT * FROM pg_depend WHERE refobjid='staging'::regnamespace;