Home > database > How a lot of oracle delete table data, according to the time dimension to delete
How a lot of oracle delete table data, according to the time dimension to delete
Time:09-15
Are made before the delete to delete a few data, no contact with such a large number of deleted, now a little helpless, trouble bosses help There is a table for: INTERFACE_FROM_LOG, has more than 1000 W data To: REQUEST_TIME this time field is less than the 2020-01-01 this condition to delete Could you tell me how to write big specific SQL the?
CodePudding user response:
Bosses, for help
CodePudding user response:
Didn't understand, what is the relationship between more than one thousand, as the delete
CodePudding user response:
I novice small white, LZ try this line not line, a timebox delete The delete from interface_from_log where request_time between to_date (' 2018-01-01 00:00:00 ', 'yy - mm - dd hh24: mi: ss') and to_date (' 2020-01-01 ', 'yy - mm - dd hh24: mi: ss')
CodePudding user response:
If direct delete, cause memory still occupied, this how to solve?
CodePudding user response:
Partial deletion went, every time delete line 10000, delete completed immediately perform a commit;
CodePudding user response:
Simple and crude, according to the time to add partition, need to delete data, directly deleted partitions,
CodePudding user response:
Give you an idea, if you remove most of the data in the table, can CTAS new table of the need to keep the data inserted into a new table, and then rename way switch,
CodePudding user response:
Don't delete 1, the CREATE TABLE INTERFACE_FROM_LOG_BAK AS SELECT * FROM INTERFACE_FROM_LOG WHERE REQUEST_TIME & gt;='2020-01-01'; Do you have any questions - select see retain data 2, the DROP TABLE INTERFACE_FROM_LOG; 3, CREATE TABLE INTERFACE_FROM_LOG AS SELECT * FROM INTERFACE_FROM_LOG_BAK;
CodePudding user response:
Too much rollback segments will not use the delete data and line by line operation is slow, even by the host's commit delete or slow, bypassing the delete directly
CodePudding user response:
If long-term have this operation demand or considering building partition table is better, as you delete selected conditions