The PostgreSQL administration field guideField notes · Runbooks · Free certification

Section 1 of 3 · 6 minutes

Identify the service you are using

Your goal

What you will be able to do

Identify the server version, database, schema, and role for your current connection.

Why this matters at work

The practical reason

The same server can contain several databases, and the same database can contain several schemas.

Learn

The idea in plain English

A PostgreSQL cluster is one running PostgreSQL service and its data directory. A cluster can hold many databases. Each database can hold many schemas, which organise tables and other objects.

Your connection selects one database and one role. PostgreSQL also uses a search path to decide which schema an unqualified table name refers to. Check this context before you investigate or change anything.

Remember these points

  • A cluster is the whole PostgreSQL service, not one database.
  • A connection works inside one database at a time.
  • A schema groups objects inside a database.

See it in SQL

Show the current connection context

Confirm exactly where this SQL session is running.

SELECT
  version() AS server_version,
  current_database() AS database_name,
  current_schema() AS schema_name,
  current_user AS role_name;

`version()` reports the PostgreSQL build. The three `current_` values come from this session, so they describe the connection you are actually using.

Save these values with a timestamp when you collect incident evidence. They prevent results from two services being mixed together.

What you should see

One row containing the PostgreSQL version, current database, current schema, and current role.

Useful words

Important terms

Cluster
One PostgreSQL service and the data files it manages.
Schema
A named group of objects inside one database.

Quick check · Not graded

Check your understanding

Which statement correctly describes a PostgreSQL cluster?

Choose one answer

Your progress is saved to your signed-in account.