0
0
PostgreSQLquery~5 mins

Creating and switching schemas in PostgreSQL - Quick Revision & Summary

Choose your learning style9 modes available
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'?
AMAKE SCHEMA inventory;
BNEW SCHEMA inventory;
CCREATE SCHEMA inventory;
DADD SCHEMA inventory;
How do you tell PostgreSQL to look in the 'marketing' schema first when running queries?
ACHANGE schema TO marketing;
BUSE marketing;
CSET schema TO marketing;
DSET search_path TO marketing;
If you run SET search_path TO sales, public;, which schema is checked first?
Asales
BNone
CBoth at the same time
Dpublic
What is the default schema in PostgreSQL if you don't change the search path?
Asales
Bpublic
Cdefault
Dmain
Why might you want to create multiple schemas in one database?
ATo organize tables by project or team
BTo make the database slower
CTo delete data faster
DTo avoid using tables
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.