gerenciar esquemas
Este artigo mostra como view, atualizar e excluir esquemas em Unity Catalog.
Consulte também O que são esquemas em Databricks? e Criar esquemas.
Em Hive metastore, o senhor deve usar um comando SQL para gerenciar esquemas. O comportamento no legado Hive metastore é diferente de Unity Catalog. As permissões necessárias dependem do fato de o senhor estar ou não usando o controle de acesso da tabela. Consulte Schemas em Hive metastore e Hive metastore privileges and securable objects (legacy).
Antes de começar
Para trabalhar com esquemas no Unity Catalog:
- O senhor deve ter um metastore Unity Catalog vinculado ao workspace onde realiza a criação do esquema.
- O clustering que o senhor usa para executar um Notebook para gerenciar um esquema deve usar um modo de acesso compatível com o Unity Catalog. Consulte Modos de acesso. SQL O armazém sempre oferece suporte ao site Unity Catalog.
- As permissões necessárias para alterar, view, e eliminar esquemas em Unity Catalog estão listadas nas seções a seguir.
Localizar e view esquemas
No Unity Catalog, os usuários podem ver todos os esquemas aos quais foi atribuída a permissão USE SCHEMA
, juntamente com a permissão USE CATALOG
no catálogo pai do esquema. Para acessar ou listar uma tabela ou view em um esquema, os usuários também devem ter permissão SELECT
na tabela ou view.
- Catalog Explorer
- SQL
- Log in to a workspace that is linked to the Unity Catalog metastore.
- Click
Catalog.
- In the Catalog pane on the left, click the catalog that contains the schema (
hive_metastore
if it’s in the Hive metastore).
Alternatively, you can search for the schema using the Type to filter field in the Catalog pane.
Run SHOW SCHEMAS
in a notebook or the SQL query editor to list all schemas in a catalog or those that match a regular expression. Run DESCRIBE SCHEMA
to get details about a schema. See SHOW SCHEMAS and DESCRIBE SCHEMA.
Atualizar um esquema
Para atualizar (ou alterar) um esquema em um catálogo do Unity Catalog, o senhor pode usar o Catalog Explorer ou um comando SQL.
Permissões necessárias : As permissões necessárias para atualizar um esquema no Unity Catalog dependem da atualização:
- Para alterar o proprietário, você deve ser o proprietário ou ter
MANAGE
eUSE SCHEMA
no esquema eUSE CATALOG
no catálogo principal. - Para renomear o esquema, você deve ser o proprietário ou ter
MANAGE
eUSE SCHEMA
no esquema eUSE CATALOG
no catálogo principal. - Para adicionar ou atualizar um comentário, você deve ser o proprietário ou ter
USE SCHEMA
eMANAGE
ouMODIFY
no esquema eUSE CATALOG
no catálogo principal. - Para adicionar ou atualizar uma tag, você deve ser o proprietário ou ter
USE SCHEMA
eMODIFY
no esquema eUSE CATALOG
no catálogo principal. - Para adicionar uma tabela, você deve ser o proprietário do esquema ou ter
USE SCHEMA
eCREATE TABLE
no esquema eUSE CATALOG
no catálogo principal. - Para adicionar um volume, você deve ser o proprietário do esquema ou ter
USE SCHEMA
eCREATE VOLUME
no esquema eUSE CATALOG
no catálogo principal. - Para conceder e revogar permissões no esquema, você deve ser o proprietário do esquema, o proprietário do catálogo principal, um administrador da metastore ou ter
MANAGE
eUSE SCHEMA
no esquema eUSE CATALOG
no catálogo principal.
- Catalog Explorer
- SQL
-
Log into a workspace that is linked to the Unity Catalog metastore.
-
Click
Catalog.
-
In the Catalog pane on the left, click the catalog that contains the schema and then click the schema to open the schema details page.
Alternatively, you can search for the schema using the Type to filter field in the Catalog pane.
-
Use the following page elements on the schema details page to update the schema:
- Overview tab: update the owner, add or update tags, add or update comments. See Manage Unity Catalog object ownership, Apply tags to Unity Catalog securable objects, and Add comments to data and AI assets.
- Permissions tab: grant and revoke privileges on the schema. See Manage privileges in Unity Catalog.
- The
kebab menu: Rename the schema.
- Create button: create a table or volume in the schema. See Create or modify a table using file upload and What are Unity Catalog volumes?.
- To change the owner, add or update tags, set schema properties, and manage predictive optimization on the tables in a schema, run the
ALTER SCHEMA
command in a notebook or the SQL query editor. See ALTER SCHEMA. - To grant or revoke privileges, use the
GRANT
orREVOKE
command. See GRANT and REVOKE. - To add tables, volumes, and other data and AI assets to a schema, see the documentation for creating the asset (for example What is a table? or Manage model lifecycle in Unity Catalog).
- To rename a schema using SQL, you must create a new schema and move all assets into the new schema.
Excluir um esquema
Para excluir (ou soltar) um esquema em um catálogo do Unity Catalog, o senhor pode usar o Catalog Explorer ou um comando SQL.
Permissões necessárias : Para descartar um esquema no Unity Catalog, o senhor deve ser seu proprietário.
- Catalog Explorer
- SQL
You must delete all tables in the schema before you can delete it.
- Log in to a workspace that is linked to the metastore.
- Click
Catalog.
- In the Catalog pane, on the left, click the schema that you want to delete.
- In the detail pane, click the kebab menu
in the upper right corner and select Delete.
- On the Delete schema dialog, click Delete.
Run the following SQL command in a notebook or the SQL query editor. Items in brackets are optional. Replace the placeholder <schema-name>
.
For parameter descriptions, see DROP SCHEMA.
If you use DROP SCHEMA
without the CASCADE
option, you must delete all tables in the schema before you can delete it.
DROP SCHEMA [ IF EXISTS ] <schema-name> [ RESTRICT | CASCADE ]
For example, to delete a schema named inventory_schema
and its tables:
DROP SCHEMA inventory_schema CASCADE
Próximas etapas
Para saber como adicionar tabelas e volumes ao seu esquema, consulte O que é uma tabela? e What are Unity Catalog volumes (O que são volumes do Unity Catalog?).