0
0
PostgreSQLquery~10 mins

Schemas for namespace organization in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new schema named 'sales'.

PostgreSQL
CREATE SCHEMA [1];
Drag options to blanks, or click blank then click option'
Asales
Bdatabase
Ctable
Dpublic
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'database' or 'table' instead of a schema name.
Trying to create a schema without a name.
2fill in blank
medium

Complete the code to set the search path to the 'sales' schema.

PostgreSQL
SET search_path TO [1];
Drag options to blanks, or click blank then click option'
Apublic
Bsales
Cmain
Ddefault
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'public' when the goal is to use 'sales'.
Using invalid schema names.
3fill in blank
hard

Fix the error in the code to create a table named 'orders' inside the 'sales' schema.

PostgreSQL
CREATE TABLE [1].orders (id SERIAL PRIMARY KEY, amount NUMERIC);
Drag options to blanks, or click blank then click option'
Apublic
Bdefault
Cmain
Dsales
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the schema name and creating the table in the default schema.
Using a schema name that does not exist.
4fill in blank
hard

Fill both blanks to query all rows from the 'orders' table in the 'sales' schema.

PostgreSQL
SELECT * FROM [1].[2];
Drag options to blanks, or click blank then click option'
Asales
Borders
Cpublic
Dcustomers
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping schema and table names.
Using the wrong schema or table name.
5fill in blank
hard

Fill all three blanks to grant SELECT permission on the 'orders' table in the 'sales' schema to user 'analyst'.

PostgreSQL
GRANT [1] ON [2].[3] TO analyst;
Drag options to blanks, or click blank then click option'
ASELECT
Bsales
Corders
DUPDATE
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong permission like UPDATE instead of SELECT.
Mixing up schema and table names.