Drops an existing schema (if it exists) in the specified database and then creates a new empty schema. If the connection is to a MotherDuck instance, the function switches to the given database first, then drops and recreates the schema. Displays helpful CLI output about the current connection, user, and database.
delete_and_create_schema(.con, database_name, schema_name)Invisibly returns NULL.
Side effect: drops and recreates the schema and prints CLI status messages.
A valid DBI connection (DuckDB / MotherDuck).
The name of the database where the schema should be dropped and recreated.
The name of the schema to drop and recreate.
Executes DROP SCHEMA IF EXISTS ... CASCADE to remove an existing schema
and all contained objects.
Executes CREATE SCHEMA IF NOT EXISTS to recreate it.
If connected to MotherDuck (detected by
validate_md_connection_status()), performs a USE <database> first.
Prints a summary of the current connection and schema creation status using internal CLI helpers.
Other db-manage:
alter_table_schema(),
copy_tables_to_new_location(),
create_database(),
create_if_not_exists_share(),
create_or_replace_share(),
create_schema(),
create_table(),
delete_database(),
delete_schema(),
delete_table(),
describe_share(),
drop_share(),
list_owned_shares(),
list_shared_with_me_shares(),
upload_database_to_md()