If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Delete All Rows From a table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-04-06, 01:02
shrivatsa shrivatsa is offline
Registered User
 
Join Date: May 2006
Posts: 9
Delete All Rows From a table

Hi all,

Can anyone give me a query to delete all the rows from a table?

Or just in simple I want to Empty the Table.
Reply With Quote
  #2 (permalink)  
Old 05-04-06, 01:10
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
delete from table-name

Since there is no where clause, then all rows are affected.

If there are a large number of rows, your transaction log may fill up, since all the deletes are in a single unit of work. There are ways around this such as:

1. Alter table to not logged initially (search this forum for details).

2. Load table from /dev/null file with replace option.

3. Increase log file size, and number of primary and secondary logs
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 05-04-06, 01:34
shrivatsa shrivatsa is offline
Registered User
 
Join Date: May 2006
Posts: 9
Hi,

I am working in Mainframe and when I try to delete all the rows first I got -904 and now its went to COPY PENDING

Can any one help me what to do if it went to copy pending state?
Reply With Quote
  #4 (permalink)  
Old 05-04-06, 01:37
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Run the image copy (backup) utility on the tablespace.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #5 (permalink)  
Old 05-04-06, 01:46
shrivatsa shrivatsa is offline
Registered User
 
Join Date: May 2006
Posts: 9
Can you tell me how to run the image copy, Does it require any DBA authority?
Reply With Quote
  #6 (permalink)  
Old 05-04-06, 01:56
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
For details, see the COPY utility in the Utility Reference Guide.

Authorization required for COPY utility: To execute this utility, the privilege set of the process must include one of the following:

- IMAGCOPY privilege for the database
- DBADM, DBCTRL, or DBMAINT authority for the database
- SYSCTRL or SYSADM authority
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #7 (permalink)  
Old 05-22-06, 11:52
venky5436 venky5436 is offline
Registered User
 
Join Date: Jul 2005
Posts: 47
Alter table Schemaname.Tablename activate not logged initially with empty table;
OR
Load from empty.del of del messages msg.out replace into Schemaname.Tablename nonrecoverable;
OR
Alter table Schemaname.Tablename activate not logged initially ;
delete from Schemaname.Tablename ;
Reply With Quote
  #8 (permalink)  
Old 05-22-06, 12:21
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by venky5436
Alter table Schemaname.Tablename activate not logged initially with empty table;
OR
Load from empty.del of del messages msg.out replace into Schemaname.Tablename nonrecoverable;
OR
Alter table Schemaname.Tablename activate not logged initially ;
delete from Schemaname.Tablename ;
You missed the part where the OP said it is on the mainframe.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #9 (permalink)  
Old 05-22-06, 13:00
venky5436 venky5436 is offline
Registered User
 
Join Date: Jul 2005
Posts: 47
I am sorry I really missed that part. Thanks for the correction Marcus.Yes it is for DB2 on LUW I do not know about mainframes.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On