Home » SQL & PL/SQL » SQL & PL/SQL » Truncating a column
Truncating a column [message #9263] Wed, 29 October 2003 14:17 Go to next message
Tony Grace
Messages: 23
Registered: August 2003
Junior Member
Is there a way to just truncate one column without truncating the whoel table?
Re: Truncating a column [message #9265 is a reply to message #9263] Wed, 29 October 2003 14:20 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
No, TRUNCATE is a DDL operation that applies to a table. It makes no sense really in the context of a single column.
Re: Truncating a column [message #9271 is a reply to message #9263] Thu, 30 October 2003 01:00 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
In addition to what Todd said:
A truncate just resets the High Water Mark (HWM) for a table. The HWM is the point that marks the upper boundary of a tables' data, i.e. the last block assigned to this table containing data. So when you perform a full table scan on a table, the data blocks will be read until the HWM is reached.

TRUNCATE will place the HWM in the first block assigned to the table and reset the space allocated to the initial storage parameters, without actually deleting data. The data is just 'forgotten' and won't be read since the HWM is being placed before them.

The main reason for this statement is: If you delete from a table, the High Water Mark will remain, so will the extents. So a full table scan will still pass ALL the blocks that contain or have contained (at one point in time) data. This is necessary because a database block might still contain SOME data. All the disk space allocated (extents etc.) will remain too for the same reason.

Now you might understand why the TRUNCATE statement cannot be seen as a DML operation, but it is DDL that affects an entire table.

For more info I refer to the Oracle documentation (http://tahiti.oracle.com) and AskTom (http://asktom.oracle.com). Tom Kyte is usually very clear and straight-forward in his explanation and, even more important, uses real life examples a lot.

HTH,
MHE
Re: Truncating a column [message #9290 is a reply to message #9265] Fri, 31 October 2003 06:47 Go to previous messageGo to next message
Tony Grace
Messages: 23
Registered: August 2003
Junior Member
So the only way to clear the values of the data within a particular column is through an sql statement?

what kind of sql statment would that be?
Re: Truncating a column [message #9291 is a reply to message #9290] Fri, 31 October 2003 09:05 Go to previous message
GT_Back
Messages: 10
Registered: October 2003
Junior Member
Update table_name set column_name = null;

commit;
Previous Topic: DBMS_SQL.DEFINE_COLUMN
Next Topic: SQL Query : Performance Isssue
Goto Forum:
  


Current Time: Thu Apr 25 23:08:13 CDT 2024