Table of Contents

Drop & Empty

Foundry provides commands to remove database objects (foundry drop) and to clear the contents of a table or a schema (foundry empty), without requiring you to write DDL or DML yourself.

Warning

drop and empty operations are destructive and cannot be undone. Always verify the target before executing, particularly in production environments.


Drop

The foundry drop command removes database objects. Each subcommand targets a specific object type and requires you to explicitly identify the target.

All drop subcommands accept the standard connection options.

foundry drop schema

Drops a schema and all objects it contains.

foundry drop schema --schema <NAME> [connection options]
foundry drop schema --datasource connection.json --schema archive

foundry drop schema \
  --datasource PostgreSQL_17.6.json \
  --schema staging

foundry drop table

Drops a single table.

foundry drop table --schema <NAME> --table <NAME> [connection options]
foundry drop table \
  --datasource connection.json \
  --schema dbo --table temp_import

foundry drop table \
  --conn "Server=localhost;Database=mydb;User Id=sa;Password=pass" --db SQLServer \
  --schema dbo --table old_archive

foundry drop view

Drops a view.

foundry drop view --schema <NAME> --view <NAME> [connection options]
foundry drop view \
  --datasource connection.json \
  --schema dbo --view vw_active_customers

foundry drop view \
  --datasource PostgreSQL_17.6.json \
  --schema public --view vw_monthly_summary

foundry drop index

Drops a named index from a table.

foundry drop index --schema <NAME> --table <NAME> --index <NAME> [connection options]
foundry drop index \
  --datasource connection.json \
  --schema dbo --table orders --index IX_orders_customer_id

foundry drop index \
  --conn "Host=localhost;Database=mydb;Username=postgres;Password=pass" --db PostgreSQL \
  --schema public --table products --index IX_products_sku

foundry drop full-text-index

Drops the full-text index from a table.

foundry drop full-text-index --schema <NAME> --table <NAME> [connection options]
foundry drop full-text-index \
  --datasource connection.json \
  --schema dbo --table articles

foundry drop full-text-index \
  --datasource MySql_8.4.json \
  --schema blog --table posts

foundry drop spatial-index

Drops the spatial index from a table.

foundry drop spatial-index --schema <NAME> --table <NAME> [connection options]
foundry drop spatial-index \
  --datasource PostgreSQL_17.6.json \
  --schema public --table locations

foundry drop spatial-index \
  --datasource connection.json \
  --schema dbo --table sites

Empty

The foundry empty command removes the contents of a table or a schema without removing the table or schema itself. What "contents" means differs by level:

  • empty table deletes rows from a single table. The table, its columns, indexes, and constraints are untouched.
  • empty schema drops every table, view, index, and constraint contained in the schema. This is a structural operation, not a row-level delete — but the schema itself is never dropped, so an emptied schema is left behind as a valid, empty container.

empty schema exists mainly to prepare a schema for foundry drop schema on engines that refuse to drop a non-empty schema/database container outright (DB2, SQL Server, and Teradata). On those engines, run empty schema first, then drop schema to remove the now-empty container.

foundry empty schema

Drops every table, view, index, and constraint in a schema, leaving the empty schema itself in place.

foundry empty schema --schema <NAME> [options]
Option Short Description
--schema <NAME> -s Name of the schema to empty
--ignore-failures Continue if an individual object cannot be dropped
foundry empty schema --datasource connection.json --schema dbo

# Continue past objects that fail to drop (e.g. due to FK constraints)
foundry empty schema \
  --datasource connection.json \
  --schema dbo --ignore-failures
Note

empty schema drops objects, it does not truncate rows — table structure is not preserved. If you only want to clear a table's data and keep its structure, use foundry empty table instead. Use --ignore-failures to skip objects that can't be dropped (e.g. due to foreign key constraints) and continue emptying the rest of the schema.


foundry empty table

Removes all rows from a single table.

foundry empty table --schema <NAME> --table <NAME> [connection options]
foundry empty table \
  --datasource connection.json \
  --schema public --table staging_data

foundry empty table \
  --conn "Server=localhost;Database=mydb;User Id=sa;Password=pass" --db SQLServer \
  --schema dbo --table audit_log