Complete the code to create a new schema named 'sales'.
CREATE SCHEMA [1];The CREATE SCHEMA command followed by the schema name creates a new schema. Here, 'sales' is the schema name.
Complete the code to set the search path to the 'sales' schema.
SET search_path TO [1];The SET search_path TO command changes the schema search order. Setting it to 'sales' makes that schema the default for object lookups.
Fix the error in the code to create a table named 'orders' inside the 'sales' schema.
CREATE TABLE [1].orders (id SERIAL PRIMARY KEY, amount NUMERIC);To create a table inside a specific schema, prefix the table name with the schema name and a dot. Here, 'sales.orders' creates the table in the 'sales' schema.
Fill both blanks to query all rows from the 'orders' table in the 'sales' schema.
SELECT * FROM [1].[2];
To query a table in a specific schema, use schema_name.table_name. Here, 'sales.orders' selects from the 'orders' table in the 'sales' schema.
Fill all three blanks to grant SELECT permission on the 'orders' table in the 'sales' schema to user 'analyst'.
GRANT [1] ON [2].[3] TO analyst;
The GRANT SELECT ON schema.table TO user command gives read permission on the table. Here, 'SELECT' is the permission, 'sales' is the schema, and 'orders' is the table.