UŻYJ SCHEMATU

Dotyczy:zaznacz pole wyboru oznaczone jako tak Databricks SQL zaznacz pole wyboru oznaczone jako tak Databricks Runtime 10.4 LTS i nowsze

Ustawia bieżący schemat. Po ustawieniu bieżącego schematu niekwalifikowane odwołania do obiektów, takich jak tabele, funkcje i widoki, do których odwołuje się sqls, są rozpoznawane z bieżącego schematu. Domyślna nazwa schematu to default.

Chociaż użycie SCHEMA elementów i DATABASE jest wymienne, SCHEMA jest preferowane.

Składnia

USE [SCHEMA] schema_name

Parametr

Przykłady

-- Use the 'userschema' which exists.
> USE SCHEMA userschema;

-- Use the 'userschema1' which doesn't exist
> USE SCHEMA userschema1;
  Error: Database 'userschema1' not found;

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

-- Setting the schema within the current catalog
> USE SCHEMA some_schem;
> SELECT current_catalog(), current_schema();
  some_cat some_schema

-- Resetting both catalog and schema
> USE CATALOG main;
> USE SCHEMA my_schema;
> SELECT current_catalog(), current_schema();
  main my_schema

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