Hkesharwani
Contributor II

In Databricks, you cannot directly rename a schema using a specific SQL statement like ALTER SCHEMA or RENAME SCHEMA. However, you can achieve a similar result by following these steps:

  1. Create a new schema with the desired name using the CREATE SCHEMA statement.
  2. Transfer all the (tables, views, functions, etc.) from the old schema to the new schema using ALTER TABLE, ALTER VIEW, or other appropriate statements. 
    ALTER TABLE old_schema.table_name SET SCHEMA new_schema;
    ALTER VIEW old_schema.view_name SET SCHEMA new_schema;
  3. Update any references to the old schema in your code or queries to use the new schema name.
  4. Finally, if you no longer need the old schema, you can drop it using the DROP SCHEMA statement.

Harshit Kesharwani
Data engineer at Rsystema