Partilhar via


CATÁLOGO DE UTILIZAÇÃO

Aplica-se a:Marque Sim Databricks SQL Marque Sim Databricks Runtime 10.4 LTS e superior Marque Sim somente Unity Catalog

Define o catálogo atual. Depois que o catálogo atual é definido, identificadores parciais e não qualificados para tabelas, funções e exibições referenciadas por SQLs são resolvidos a partir do catálogo atual.

A configuração do catálogo também redefine o esquema atual como default.

Sintaxe

{ USE | SET } CATALOG [ catalog_name | ' catalog_name ' ]

Parâmetro

  • catalog_name

    Nome do catálogo a ser usado. Se o catálogo não existir, uma exceção será lançada.

Exemplos

-- Use the 'hive_metastore' which exists.
> USE CATALOG hive_metastore;

> USE CATALOG 'hive_metastore';

-- Use the 'some_catalog' which doesn't exist
> USE CATALOG `some_catalog`;
  Error: Catalog 'some_catalog' not found;

-- Setting the catalog resets the datbase to `default`
> USE CATALOG some_cat;
> SELECT  current_catalog(), current_database();
  some_cat default

-- Setting the schema within the curret catalog
> USE DATABASE some_db;
> SELECT  current_catalog(), current_database();
  some_cat some_db

-- Resetting both catalog and schema
> USE DATABASE main.my_db;
> SELECT  current_catalog(), current_database();
  main my_db

-- Setting the catalog resets the database to `default` again
> USE CATALOG some_cat;
> SELECT  current_catalog(), current_database();
  some_cat default