473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

TRUNCATE stored procedure

The following link includes an example of a stored procedure that can be
used to truncate a table without logging:

http://publib.boulder.ibm.com/infoce...topic=/com.ibm.
db2.udb.apdv.sample.doc/doc/admin_scripts/s-truncate-db2.htm

It uses "IMPORT FROM NUL OF DEL REPLACE INTO ...", where other examples of
this type of thing seem to use LOAD instead of IMPORT.

Any thoughts as to why one method might be prefered over the other?

Frank

Jun 27 '08 #1
3 4443
Frank Swarbrick wrote:
It uses "IMPORT FROM NUL OF DEL REPLACE INTO ...", where other examples
of this type of thing seem to use LOAD instead of IMPORT.
The IMPORT-based method
- requires less privileges than other methods
- if fully recoverable

See also http://groups.google.com/group/comp....ba85f541175295

--
Regards,
Troels Arvin <tr****@arvin.dk>
http://troels.arvin.dk/
Jun 27 '08 #2
>>On 5/22/2008 at 3:51 PM, in message <g1**********@news.net.uni-c.dk>,
Troels Arvin<tr****@arvin.dkwrote:
Frank Swarbrick wrote:
>It uses "IMPORT FROM NUL OF DEL REPLACE INTO ...", where other examples
of this type of thing seem to use LOAD instead of IMPORT.

The IMPORT-based method
- requires less privileges than other methods
- if fully recoverable

See also
http://groups.google.com/group/comp....se_frm/thread/
cc36736aa9b81c6c/a0ba85f541175295
Does this mean that IMPORT does logging?
If so, why would this method be preferred over just a plain DELETE FROM
<tablestatement?

In the case I'm looking for it's simply for truncating a table for testing,
so I can rerun the test and insert the data again. I assume in this case I
would not care about it being recoverable.

Frank
Jun 27 '08 #3
Ian
Frank Swarbrick wrote:
>>>On 5/22/2008 at 3:51 PM, in message <g1**********@news.net.uni-c.dk>,
Troels Arvin<tr****@arvin.dkwrote:
>Frank Swarbrick wrote:
>>It uses "IMPORT FROM NUL OF DEL REPLACE INTO ...", where other examples
of this type of thing seem to use LOAD instead of IMPORT.
The IMPORT-based method
- requires less privileges than other methods
- if fully recoverable

See also
http://groups.google.com/group/comp....se_frm/thread/
cc36736aa9b81c6c/a0ba85f541175295

Does this mean that IMPORT does logging?
If so, why would this method be preferred over just a plain DELETE FROM
<tablestatement?
Yes, but it just logs a small record indicating that the table was
replaced (truncated).

Obviously this is much more efficient than logging each record that is
deleted.

In the case I'm looking for it's simply for truncating a table for testing,
so I can rerun the test and insert the data again. I assume in this case I
would not care about it being recoverable.
That could certainly be the case.

Remember, "recoverable" only applies if your database is enabled for
archive logging.
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rdraider | last post by:
Hi, I am trying to create a script that deletes transaction tables and leaves master data like customer, vendors, inventory items, etc. How can I use TRUNCATE TABLE with an Exists? My problem is...
9
by: Sumanth | last post by:
Are there any implementations of truncate in db2. Is it going to be implemented in the future? Is there an alternate way of doing a truncate of a table that has a high record count without using...
8
by: Stefan | last post by:
Hi all, two questions: - is there a way to call the INSERT-Statement from Java (JDBC). (import from file of del replace into table) - in db2 there is no truncate-statement, is it? Is in db2...
14
by: Sala | last post by:
Hi I want to truncate all data in database ... pls help me how i ll truncate?
1
by: hedgracer | last post by:
I would like to allow a particular user to truncate a log file in a stored procedure that the user runs every day. At this moment the only personnel that can truncate the log file are personnel...
1
by: wquatan | last post by:
Hi, I have a SQL Server 2005, used in combination with Access VBA. The SQL Server uses Windows Authenticatiob I want to do "Truncate Table" from within VBA. At first I wrote the Truncate...
3
by: Henry J. | last post by:
I know that we can use import or load to truncate tables without filling up trans log in DB2. Is it possible to do this in a stored procedure? How about in CLI/C++? My impression is that...
8
by: orajit | last post by:
Hello, I have one concern , I have one table that contains huge data. I have created one procedure inside that procedure I am truncating that table . It takes very long time to execute that....
8
by: ananthaisin | last post by:
How to reduce the table size for any table while using truncate or delete statements. In oracle 8i it was truncating the storage space but in 10g it is not .... I have given truncate statement in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.