fhg
Volume 11, Number 11 -- March 23, 2011

No Truncate Table? No Problem!

Published: March 23, 2011

Hey, Ted:

I am working on a project using DB2 for i, but my experience is with other database management systems. I can't find the SQL TRUNCATE TABLE statement. Does DB2 cover this functionality some other way?

--Brad


Even in 7.1, the latest release, IBM does not implement the TRUNCATE TABLE statement. However, since this statement is included in other DB2 products, as well as in Informix, I expect we'll see it eventually as part of our world.

For the benefit of readers who are not familiar with TRUNCATE TABLE, this statement removes all rows of a table (records of a physical file) without dropping the table (deleting the physical file). It is the SQL equivalent of the Clear Physical File (CLRPFM) CL command.

In the meantime, you have nothing to worry about, because this functionality is indeed covered by a feature of the DELETE statement.

When you issue a DELETE without a WHERE clause, you are telling the system to remove all records from the table. If the table is small, the database engine will probably delete the rows individually. However, if the table is large, the system may use either a clear operation (when commitment control is not active) or a change file operation (when commitment control is active.)

I did a quick experiment with two sequential physical files (not SQL tables) that illustrates this point. Commitment control was not active.

One file had 12 records. After I ran a DELETE without a WHERE, Display File Description (DSPFD) showed zero active records and 12 deleted ones.

The second file had about 255,000 records. After a DELETE with no WHERE, DSPFD showed zero active records and zero deleted ones.

Of course, you can always fall back on CLRPFM. It works on all types of physical files, including SQL tables, even when those tables are journaled.

--Ted




                     Post this story to del.icio.us
               Post this story to Digg
    Post this story to Slashdot


Sponsored By
PRODATA COMPUTER SERVICES

DBU 9.0 Now Available!

                                                        Just when you thought DBU had it all,
                                                        we've added MORE!

                                                            New DBUSQL command
                                                            Enhanced Audit Logging
                                                            Execute DBUJRN in batch
                                                            Supports DBCS for Chinese, Korean
                                                              and Japanese
                                                            Wizard-based DBU security set-up

                                                        And MORE!

Download today!
800.228.6318
www.DoDBU.com


Senior Technical Editor: Ted Holt
Technical Editor: Joe Hertvik
Contributing Technical Editors: Edwin Earley, Brian Kelly, Michael Sansoterra
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

Sponsored Links

SEQUEL Software:  FREE Webinar: Overcoming query limits with SEQUEL. March 23
Northeast User Groups Conference:  21th Annual Conference, April 11 - 13, Framingham, MA
looksoftware:  Integrate IBM i apps with web services. FREE on-demand webinar and white paper!


 

IT Jungle Store Top Book Picks

BACK IN STOCK: Easy Steps to Internet Programming for System i: List Price, $49.95

The iSeries Express Web Implementer's Guide: List Price, $49.95
The iSeries Pocket Database Guide: List Price, $59
The iSeries Pocket SQL Guide: List Price, $59
The iSeries Pocket WebFacing Primer: List Price, $39
Migrating to WebSphere Express for iSeries: List Price, $49
Getting Started with WebSphere Express for iSeries: List Price, $49
The All-Everything Operating System: List Price, $35
The Best Joomla! Tutorial Ever!: List Price, $19.95


 
The Four Hundred
IBM Hikes Maintenance Fees on Power-Based Gear

IBM, Oracle to Build on i Solution Edition Momentum

Calculating the Risks on All Sides of the App Modernization Issue

As I See It: Rethinking the Resolution

IBM to Ride Growth Waves on Current Iron in 2011

Four Hundred Stuff
ExtraHop Adds DB2 to Database Performance-Tracking Repertoire

InterForm Sees New Opportunities in IBM i Forms Management

Early Adopters of Profound UI Pleased

Quadrant Touts Replacement for Withdrawn IBM Domino Fax for i5/OS

Security of SecurID In Question Following Hack of RSA

Four Hundred Monitor
Four Hundred Monitor's
Full iSeries Events Calendar

System i PTF Guide
September 25, 2010: Volume 12, Number 39

September 18, 2010: Volume 12, Number 38

September 11, 2010: Volume 12, Number 37

September 4, 2010: Volume 12, Number 36

August 28, 2010: Volume 12, Number 35

August 21, 2010: Volume 12, Number 34

TPM at The Register
Oracle puts out Solaris 11 compatibility tester

Cray to build huge, grunting 20-petaflop 'Titan' for US gov labs

Intel eyes up HP chief for top job

IBM: Our appliance servers smoke Ellison's 'phony baloney'

IBM accused of bribery in China, South Korea

Cisco shells out first dividend

Supercomputer charts killer tsunami's course

Intel buys Silicon Hive for SoC smarts

IBM tunes up Java for z196 mainframes

US CIOs: IT hires on the rise

GaleForce blows into the cloud

SGI talks Windows on Altix UV

THIS ISSUE SPONSORED BY:

Bytware
ProData Computer Services
Twin Data Corporation


Printer Friendly Version


TABLE OF CONTENTS
Duplicating an Entire Table or a Subset of a Table Using SQL

No Truncate Table? No Problem!

Automatically Deleting Spooled Files through Expiration Dates

Four Hundred Guru

BACK ISSUES




 
Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2011 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement