Data truncation is the automatic or deliberate shortening of data. A string, decimal number, or datestamp can be truncated to a shorter value. A data stream (such as a file or record set) can be truncated when either the entirety of the data is not needed or when it will be stored in a location too short to hold its entire length. No rounding occurs when numbers are truncated.
Data truncation may occur automatically, such as when a long string is written to a smaller buffer, or deliberately, when only a portion of the data is wanted. The truncation principles can be used in several different ways.
###Function Calls
Many data handling programs have built in methods or functions to handle truncation. Syntax will vary, but the principles are the same. Examples include:
- Strings:
TRUNC("This is a string.", 12)=This is a st - Decimals:
TRUNC(3.14159, 2)=3.14orfloor(3.14159)=3 - Dates:
TRUNC(#7/4/2017 23:45#)=#7/4/2017 00:00#
###SQL Statement
In SQL, the TRUNCATE TABLE statement removes all rows from a table without invoking any triggered actions. The result of this operation quickly removes all data from a table, typically bypassing a number of integrity enforcing mechanisms. It was officially introduced in the SQL:2008 standard. In the SQL standard TRUNCATE TABLE is defined as a data manipulation language (DML) feature but database vendors often classify it as DDL for their own implementation-specific reasons.
The TRUNCATE TABLE mytable statement is logically (though not physically) equivalent to the DELETE FROM mytable statement (without a WHERE clause).
Datestamp values
Datestamps can be truncated. 2009-02-09 09:41:22 can be truncated, for example, to the:
- year
2009-01-01 00:00:00 - month
2009-02-01 00:00:00 - day
2009-02-09 00:00:00 - hour
2009-02-09 09:00:00
Related tags
References
Function Calls
SQL Statements