Teradata DDL Best Practice: Use DELETE Instead of DROP for Efficiency and Resource Management

Teradata DDL – DELETE, don’t DROP

To initiate the ETL process on Teradata, a simple approach involves importing data from external sources into an empty table commonly known as a ‘staging’ table. In my experience working with numerous clients, I have encountered a common practice of implementing this logic through a Fastload or TPTLoad script.

DROP TABLE staging_table;
CREATE TABLE staging_table,…;

Rest of loading script…

Although functional, this approach has notable drawbacks.

  1. Locks are placed on multiple dictionary tables – in TD14.10 there are nine tables locked including a table level write lock on DBC.ACCESSRIGHTS.
  2. The EXPLAIN plan contains 22 steps (including parallel steps).
  3. For the proverbial 99.99% of times, this logic is executed the DROP TABLE removes some dictionary rows which are then added back to the CREATE TABLE. Apart from date/time values nearly all of the data values in the new rows are identical to the old rows.
  4. It also helps to negate a lot of the work which is done to housekeep the DBC.AccessRights table (see my article titled “Redundant AccessRights – More Housekeeping!”)
  5. It is slower and uses more resources (CPU and IO) than necessary.

When advising or instructing clients, I recommend the following procedure:

DELETE FROM staging_table;
.IF ERRORCODE = 0 THEN .GOTO NODATA;
DROP TABLE staging_table;
CREATE TABLE staging_table,…;
.LABEL NODATA;

Rest of loading script…

In contrast to the previous reasoning:

  1. There are no explicit dictionary table locks.
  2. The EXPLAIN plan contains five steps.
  3. No dictionary rows are removed and then added back in.
  4. It will be faster and more efficient (same result, fewer resources).

Currently, this reasoning cannot be executed through a basic TPT script since no branching feature exists according to error codes. Consequently, two scripts must be involved, with the initial being BTEQ.

This modification won’t diminish runtime by minutes, yet is a singular piece of the puzzle in optimizing your Teradata processing.

Also, check out:
Table Cloning in Teradata

Related Services

⚡ Need Help Optimizing Your Data Platform?

We cut data platform costs by 30–60% without hardware changes. 25+ years of hands-on tuning experience.

Explore Our Services →

📋 Considering a Move From Teradata?

Get a personalized migration roadmap in 2 minutes. We have migrated billions of rows from Teradata to Snowflake, Databricks, and more.

Free Migration Assessment →

📊 Data Platform Migration Survey

Help us map where the industry is heading. Results are public — see what others chose.

1. What is your current data platform?

2. Where are you migrating to (or evaluating)?

Migrating FROM
Migrating TO

Thanks for voting! Share this with your network.

Follow me on LinkedIn for daily insights on data warehousing and platform migrations.

Stay Ahead in Data Warehousing

Get expert insights on Teradata, Snowflake, BigQuery, Databricks, Microsoft Fabric, and modern data architecture — delivered to your inbox.

Leave a Comment

DWHPro

Expert network for enterprise data platforms. Senior consultants, project teams built for your challenge — across Teradata, Snowflake, Databricks, and more.

📍Vienna, Austria & Jacksonville, Florida

Quick Links
Services Team Teradata Book Blog Contact Us
Connect
LinkedIn → [email protected]
Newsletter

Join 4,000+ data professionals.
Weekly insights on Teradata, Snowflake & data architecture.