List schemas in Azure SQL Database

The query below lists all the schemas in the Azure SQL Database. Schemas include the default db_* , sys, information_schema and guest schemas.

If you want to list only user schemas, use this script.

Query

select s.name as schema_name,
    s.schema_id,
    u.name as schema_owner
from sys.schemas s
    inner join sys.sysusers u
        on u.uid = s.principal_id
order by s.name

Columns

  • schema_name - name of the schema
  • schema_id - schema id, which is unique within the database
  • schema_owner - principal that owns this schema

Rows

  • One row: represents one schema in a database
  • Scope of rows: all schemas in a database, including the default ones
  • Ordered by: schema name

Sample results

Here is a view of database schemas in SSMS:

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.