Complete the code to select all tables from the default schema in PostgreSQL.
SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname = '[1]';
The default schema in PostgreSQL is named public. This query lists all tables in that schema.
Complete the code to create a new schema named 'sales'.
CREATE SCHEMA [1];To create a custom schema named sales, use CREATE SCHEMA sales;.
Fix the error in the code to select from a table named 'orders' in the 'sales' schema.
SELECT * FROM [1].orders;To select from a table in a custom schema, prefix the table name with the schema name, like sales.orders.
Fill both blanks to set the search path to use the 'sales' schema first, then the default schema.
SET search_path TO [1], [2];
The search_path controls which schemas PostgreSQL looks in first. Setting it to sales, public means it looks in sales first, then public.
Fill all three blanks to grant usage on the 'sales' schema to user 'alice' and allow her to create tables.
GRANT [1], [2] ON SCHEMA [3] TO alice;
Granting USAGE allows access to the schema, and CREATE allows creating tables inside it. The schema name is sales.