Thor Logo dbatools

Schema

Get-DbaDbSchema

Adam Lancaster, github.com/lancasteradam

Get-DbaDbSchema View Source Adam Lancaster, github.com/lancasteradam Windows, Linux, macOS Synopsis Retrieves database schema objects from SQL Server instances for inventory, security auditing, and management tasks Description Returns SQL Server Management Object (SMO) schema objects from one or more databases, allowing you to inspect schema ownership, enumerate database organization, and identify schema-level security configurations. This function is essential for database documentation, security auditing when you need to track who owns which schemas, and migration planning where schema ownership and structure must be preserved.

Read more

New-DbaDbSchema

Adam Lancaster, github.com/lancasteradam

New-DbaDbSchema View Source Adam Lancaster, github.com/lancasteradam Windows, Linux, macOS Synopsis Creates new database schemas with specified ownership for organizing objects and implementing security boundaries. Description Creates new database schemas within SQL Server databases, allowing you to organize database objects into logical groups and implement security boundaries. Schemas provide a way to separate tables, views, procedures, and other objects by ownership or function, which is essential for multi-tenant applications, security models, and organized database development.

Read more

Remove-DbaDbSchema

Adam Lancaster, github.com/lancasteradam

Remove-DbaDbSchema View Source Adam Lancaster, github.com/lancasteradam Windows, Linux, macOS Synopsis Removes database schemas from one or more SQL Server databases. Description Removes database schemas from SQL Server databases using the DROP SCHEMA T-SQL command. This function is useful for cleaning up unused schemas during database maintenance, development environment resets, or application decommissioning. The schema must be completely empty before removal - any tables, views, functions, or other objects within the schema will prevent the drop operation from succeeding.

Read more

Set-DbaDbSchema

Adam Lancaster, github.com/lancasteradam

Set-DbaDbSchema View Source Adam Lancaster, github.com/lancasteradam Windows, Linux, macOS Synopsis Changes the owner of database schemas to reassign security and object ownership responsibilities Description Modifies the ownership of database schemas by updating the schema owner property in SQL Server. This is commonly needed when reorganizing database security, transferring ownership from developers to service accounts, or standardizing schema ownership after database migrations. The function works by retrieving the schema object and updating its Owner property through SQL Server Management Objects, then applying the change to the database.

Read more