Recall & Review
beginner
What is a schema in PostgreSQL?
A schema is like a folder inside a database that holds tables and other objects. It helps organize data so you can keep things neat and separate.
Click to reveal answer
beginner
How do you create a new schema named 'sales' in PostgreSQL?
Use the command:
CREATE SCHEMA sales; This makes a new schema called 'sales' inside your database.Click to reveal answer
beginner
How can you switch to use a different schema in PostgreSQL?
You change the search path with:
SET search_path TO schema_name; This tells PostgreSQL to look in that schema first when you run commands.Click to reveal answer
intermediate
What does the command
SET search_path TO public, sales; do?It tells PostgreSQL to look first in the 'public' schema, then in the 'sales' schema when searching for tables or other objects.
Click to reveal answer
beginner
Why is using schemas helpful in a database?
Schemas help keep data organized, avoid name conflicts, and let different teams or projects work in the same database without mixing up their tables.Click to reveal answer
Which command creates a new schema called 'inventory'?
✗ Incorrect
The correct syntax to create a schema is
CREATE SCHEMA schema_name;.How do you tell PostgreSQL to look in the 'marketing' schema first when running queries?
✗ Incorrect
You use
SET search_path TO schema_name; to set the schema search order.If you run
SET search_path TO sales, public;, which schema is checked first?✗ Incorrect
The first schema listed in
search_path is checked first.What is the default schema in PostgreSQL if you don't change the search path?
✗ Incorrect
By default, PostgreSQL uses the 'public' schema.
Why might you want to create multiple schemas in one database?
✗ Incorrect
Schemas help organize data and avoid name conflicts by grouping tables logically.
Explain how to create a new schema and switch to it in PostgreSQL.
Think about making a folder and then telling the database to look inside it first.
You got /3 concepts.
Describe why using schemas can be helpful when multiple teams share the same database.
Imagine different teams having their own folders to keep their files separate.
You got /3 concepts.