Drop and Recreate a Schema in a MotherDuck / DuckDB Database
delete_and_create_schema.RdDrops 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.
Value
Invisibly returns `NULL`. Side effect: drops and recreates the schema and prints CLI status messages.
Details
- 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.