473,385 Members | 1,707 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.

Empty Table

Hello world,

(excuse my English) I have to empty a daily a table that has 50,000,000 record and that stores data by "date". Whenever the empties must remain only the last 3 days of data.
With DELETE
(DELETE FROM SCHEMA.TABLE WHERE DATE(AGG_TIMESTAMP) < DATE(CURRENT TIMESTAMP) - 3 DAY;).
The trasaction log are filled and delete fails. Trauncate the table can not be conditioned.

how can I do?
Sep 26 '08 #1
6 3000
docdiesel
297 Expert 100+
Hi,

the easiest and most effective way is to split the table into three and rejoin them as one view:
  • Create a table for each day, e.g. mydata20080928
  • Create a view as inner join over the three last days tables
  • If a new day/table adds, drop the old view and replace it with an updated one.
  • Drop the old days tables when not needed any more.
The "drop table" is done within a fraction of the time you need for "delete where ...". This also gives you the possibility to load the next days data (load=no logs, means less i/o and less time) without danger for the already exsiting data.

Regards

Doc Diesel
Sep 28 '08 #2
Hi,

the easiest and most effective way is to split the table into three and rejoin them as one view:
  • Create a table for each day, e.g. mydata20080928
  • Create a view as inner join over the three last days tables
  • If a new day/table adds, drop the old view and replace it with an updated one.
  • Drop the old days tables when not needed any more.
The "drop table" is done within a fraction of the time you need for "delete where ...". This also gives you the possibility to load the next days data (load=no logs, means less i/o and less time) without danger for the already exsiting data.

Regards

Doc Diesel
thanks for your answer Doc Diesel,

but I can not divide the table into 3 parts per requirements associated application that you access.

there's another way ?
Sep 29 '08 #3
sakumar9
127 Expert 100+
You can truncate the table. By the way, which DB2 are you running?

As such, there is no command like truncate in DB2. But I am sure you would like to know how it can be done in DB2. For that, I would suggest you to refer to the sample: sqllib/samples/admin_scripts/truncate.db2 script.

This will surely solve your problem.

Regards
-- Sanjay
Oct 1 '08 #4
sakumar9
127 Expert 100+
Oh I am sorry, you can truncate the table conditionally.

I would suggest you to use DB2 partitioning features like Range partitioning, MDC etc. This will boost your performance drastically. Just in fractions of seconds, you can actually delete huge data.

Let me know if you need more details regarding this. I would be more than happy to share.

Regards
-- Sanjay
Oct 1 '08 #5
Oh I am sorry, you can truncate the table conditionally.

I would suggest you to use DB2 partitioning features like Range partitioning, MDC etc. This will boost your performance drastically. Just in fractions of seconds, you can actually delete huge data.

Let me know if you need more details regarding this. I would be more than happy to share.

Regards
-- Sanjay
Hi Sanjay, Thanks for your response,
the partitioning but I had already thought ... how do I partition it for days? and then, as I organize the process that empty table? I run the drop partitions for more than three days old and at the same time they create for the other days? I feel somewhat complex as a solution ...
Oct 2 '08 #6
There is something called ROTATING PARTITIONS which will delete the data automatically.
Oct 23 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Agent Mulder | last post by:
Hi group, Almost 3 weeks ago I posted a short question here and in comp.std.c++ and I got exactly 1 respons, from Kevin Goodsell. He said he didn't want it. I post it here again, this time in a...
0
by: Phil Powell | last post by:
Based upon an article I read in http://archives.neohapsis.com/archives/mysql/2004-q1/0337.html I am trying to retrieve an "empty row" of fields from a table that may be empty. If I have this...
2
by: gabriel | last post by:
Greetings, I am adding foreign keys to a database and saving the generated scripts. What I do not understand is that all script begin with empty transactions. Why ? Example follows : /*
12
by: Stefan Weiss | last post by:
Hi. (this is somewhat similar to yesterday's thread about empty links) I noticed that Tidy issues warnings whenever it encounters empty tags, and strips those tags if cleanup was requested....
6
by: Mike P | last post by:
I have written a simple web service that basically takes a value input by a user and returns a dataset with all related data found in a database. In my client app use this code to get the data...
22
by: EMW | last post by:
Hi, I managed to create a SQL server database and a table in it. The table is empty and that brings me to my next chalenge: How can I get the info in the table in the dataset to go in an empty...
14
by: Xah Lee | last post by:
if i want to have a empty link, which way is more proper? <a href=""> <a href="#"> <a href="javascript:void(0);"> Xah xah@xahlee.org ∑ http://xahlee.org/
2
by: OceanBreeze | last post by:
Border drawn in C# Table programmatically even if several adjacent horizontal & vertical cells are empty in the table I want to programmatically have border on each and every row and column in the...
2
by: Jay | last post by:
I have a SQL Server table with nvarchar type column which has not null constraint. I am inserting empty string ("") from Java to the table column. When I export this table into .csv file using bcp...
8
by: thatcollegeguy | last post by:
http://smarterfootball.com/exits/theHTML.html I am not sure what is wrong w/ this code. The main issue is that the table that is in the initial html will empty its td but the table that I load...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.