TRUNCATE on View

Nanthakumar Yoganathan

TRUNCATE on View


Hi Team,

Is there any way i can use TRUNCATE on VIEW ?

Note : The VIEW created as select * from table where col=value.

 

 

Regards,

Nanthakumar Yoganathan

+91-9942512341

Roy Boxwell

TRUNCATE on View
(in response to Nanthakumar Yoganathan)
First on the list of things you *cannot* TRUNCATE



table-name

Identifies the table that is to be truncated. The name must identify a table that exists at the current server. The name must not identify the following objects:

a view

.

.

.







Roy Boxwell

SOFTWARE ENGINEERING GmbH and SEGUS Inc.
-Product Development-

Heinrichstrasse 83-85
40239 Duesseldorf/Germany
Tel. +49 (0)211 96149-675
Fax +49 (0)211 96149-32
Email: <mailto:[login to unmask email]> [login to unmask email]
Web http://www.seg.de http://www.seg.de

https://www.seg.de/corporate/rechtliche-hinweise/datenschutz Link zur Datenschutzerklärung


Software Engineering GmbH
Amtsgericht Düsseldorf, HRB 37894
Geschäftsführung: Gerhard Schubert, Ulf Heinrich



From: Nanthakumar Yoganathan [mailto:[login to unmask email]
Sent: Thursday, December 6, 2018 3:32 PM
To: [login to unmask email]
Subject: [DB2-L] - TRUNCATE on View




Hi Team,

Is there any way i can use TRUNCATE on VIEW ?

Note : The VIEW created as select * from table where col=value.





Regards,

Nanthakumar Yoganathan

+91-9942512341



-----End Original Message-----

Attachments

  • smime.p7s (5.1k)

Michael Hannan

RE: TRUNCATE on View
(in response to Nanthakumar Yoganathan)



In Reply to Nanthakumar Yoganathan:

Is there any way i can use TRUNCATE on VIEW ?

Note : The VIEW created as select * from table where col=value.

The simple answer is you should be using DELETE, or state what is the actual problem you are trying to solve, rather than a proposed solution. TRUNCATE is a solution to problem to delete all rows from a table, either ensuring there are no DELETE triggers, or bypassing them, similar to a LOAD bypassing triggers. Not to delete a subset of a table.

However your problem is not to delete all rows from a table, at least seems that way based on using a view with a predicate, suggesting only certain rows to be deleted. Even then, Mass DELETE is available to you as the normal solution, that does not have to log every row deleted unless have Data Capture Changes.  

Average DB2 sites might never need to use TRUNCATE. We survived without it for long.  Db2 has plenty of solutions that someone asked for but normally we won't ever need, like compressed indexes, scrollable Cursors, etc.

 

Michael Hannan,
DB2 Application Performance Specialist
CPT Global Ltd

Edited By:
Michael Hannan[Organization Members] @ Dec 07, 2018 - 12:02 PM (Europe/Berlin)
Michael Hannan[Organization Members] @ Dec 07, 2018 - 12:05 PM (Europe/Berlin)