Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 835715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:52:04+00:00 2026-05-15T04:52:04+00:00

Can any one give me the syntax to truncate a table in IBM DB2.

  • 0

Can any one give me the syntax to truncate a table in IBM DB2.

I m running the following command: truncate table tableName immediate;

The eror is DB2

SQLCODE=-104, SQLSTATE=42601, SQLERRMC=table;truncate ;JOIN , DRIVER=3.50.152
Message: An unexpected token “table” was found following “truncate “. Expected tokens may include: “JOIN “.. SQLCODE=-104, SQLSTATE=42601, DRIVER=3.50.152

The syntax matches the one specified in the reference docs of IBM : http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.sqlref/db2z_sql_truncate.htm

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:52:05+00:00Added an answer on May 15, 2026 at 4:52 am

    There is a great article about truncating, here is the Gist of DB2 stuff

    Almost follows the standard.(since version 9.7)
    DB2 requires that the IMMEDIATE keyword be added the the ordinary TRUNCATE TABLE statement, e.g.:

    TRUNCATE TABLE someschema.sometable IMMEDIATE 
    

    TRUNCATE TABLE must be the first statement in a transaction. A transaction starting with TRUNCATE TABLE may include other statements, but if the transaction is rolled back, the TRUNCATE TABLE operation is not undone.
    DB2s TRUNCATE TABLE operation has a number of optional arguments, see the documentation for more on this; especially, the REUSE STORAGE argument may be important for ad-hoc DBA tasks.
    In DB2 versions < 9.7, you may abuse the IMPORT statement. Unfortunately, you need to know which operating system the command is executed from for this to work:

    On unix-like systems:
    IMPORT FROM /dev/null OF DEL REPLACE INTO tablename
    On Windows:
    IMPORT FROM NUL OF DEL REPLACE INTO tablename
    IMPORT cannot be abused in all contexts. E.g., when working with dynamic SQL (from Java/.NET/PHP/…—not using the db2 command line processor), you need to wrap the IMPORT command in a call to ADMIN_CMD, e.g.:

    CALL ADMIN_CMD('IMPORT FROM /dev/null OF DEL REPLACE INTO tablename')
    

    IMPORT seems to be allowed in a transaction involving other operations, however it implies an immediate COMMIT operation.

    The ALTER TABLE command may also be abused to quickly empty a table, but it requires more privileges, and may cause trouble with rollforward recovery.

    This was taken from the website:
    http://troels.arvin.dk/db/rdbms/#bulk-truncate_table-db2

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can any one give me the difference between Itemsource and DataContext of Listview in
Can anyone give me an example of how I can consume the following web
Can anyone give me a clue, how to create/call function regular expression syntax in
can any one tell me how Local.name(.) xquery function works. regarding sql construction problem
I can't get a handle on the syntax. Can anyone give me a simple
Can anyone give me a complete list of string manipulation function in Microsoft SQL
Can anyone give me pointers to good books or web sites that teach how
Can anyone give me details of runtime error 3734 in Access vba. For reference
Can anyone give a concise set of real-world considerations that would drive the choice
Can anyone give me a scenario where they think busy cursors are justified? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.