Questions tagged [truncate]

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.14 or floor(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

1585 questions
0
votes
2 answers

Looping using jquery's .each

I have a string of dates in which I wish to truncate at the first comma. e.g., I would like: Today, July 9, 2014 Tomorrow, July 10, 2014 July 11, 2014 To Display: Today Tomorrow July 11 Using: var longDay = $('.daily_forecast').text(); var…
0
votes
3 answers

Jquery recursive selector

I have whole bunch of . What I want to do go through all .productlistname and truncate the text and replace the current text with the truncated version. Here is what I have so…
Mazzi
  • 939
  • 4
  • 12
  • 30
0
votes
1 answer

Why is my dictionary truncated?

My dictionary has to lists one of twitter user ID and one of screen names (harvested via tweepy. Both lists are correct, but when I try to zip them into a dictionary the screen names wind up truncated. an entry looks like this: 189754969:…
Kyle Sponable
  • 735
  • 1
  • 12
  • 31
0
votes
1 answer

Issue with document.ready function in jQuery

I am having one issue with document.ready jQuery function. On load the document.ready function is working fine. When I click on the button or href link, I want to reconnect with the document.ready function where I have set of code in JavaScript…
Vasethvan
  • 391
  • 1
  • 4
  • 12
0
votes
1 answer

How can I truncate the text to better fit available space

here is some sample code http://jsfiddle.net/XpLSZ/2/
This is a test Long…
simion314
  • 1,394
  • 16
  • 29
0
votes
1 answer

truncate command ( Hive vs SQL)

I was expecting the same behavior of truncate in SQL and HIVE. But its different. I want to confirm if I am perceiving it wrongly 1) In SQL, The following command drop table and create again. All partitions are dropped if exist mysql> truncate table…
minhas23
  • 9,291
  • 3
  • 58
  • 40
0
votes
0 answers

Truncation error on ADO insert command

I have a foreach loop run for every record in my list. When I execute it the it reaches the ExecuteNonQuery() and it throws this error: String or binary data would be truncated. The statement has been terminated. I have checked to make sure the…
0
votes
3 answers

Truncate Key Length in Python Dictionary

I have a Python dictionary that I'm trying to insert into mysql. Problem is one of the Keys of the dictionary is longer that 64 characters (the max length of a column in mysql). So I need to truncate all dictionary keys to 64 characters. The…
dfriestedt
  • 483
  • 1
  • 3
  • 18
0
votes
1 answer

Yahoo Pipes how to truncate items per feed with multiple feeds

I have a Yahoo Pipe where I bring in a number of feeds via an OPML file. Rather than using truncate to limit the resulting number of items that get exported, I want to limit the number of items on a per feed basis. So if I have 60 feeds I want the…
Lucas Young
  • 187
  • 2
  • 13
0
votes
1 answer

getting text length from lxml.html nodes and truncate

In parse_html() I am trying to parse for the text of each element and get the len() of text in each element. I want to generate a script that parses the length of text in each element and when the cumulative text length reaches a set size parameter,…
0
votes
1 answer

What is a faster way to truncate a group of tables in MySQL?

I’m using MySql 5.5.37. I’m trying to truncate data from a group of tables. I read here -- Quickest way to delete enormous MySQL table, that re-creating/renaming the tables was supposedly faster, but I’m getting errors … SET…
Dave
  • 15,639
  • 133
  • 442
  • 830
0
votes
2 answers

Get to 2 decimal places

I have this line of query here if (type = 1, (IF(ISNULL(users), '', ((SUM(actual) / 1) * 0.04/12) * if(users = "user", booked/(36/12),'') )) , 'false') the example output is 123.3333333 I want it to output just 2 decimals so it'll be like…
hearmeroar
  • 297
  • 1
  • 8
  • 18
0
votes
3 answers

Is it safe to truncate a table without using a prepared statement?

I've used the following sort of code a few times in my current project to clear out some tables. Incase it's not obvious I'm using PDO. $clearResult = $db->query('TRUNCATE TABLE table_name'); I'm currently going through and updating a few of my…
Parzival
  • 29
  • 8
0
votes
1 answer

Replacing data in tables with constraints

How can I import data into a total of 7 tables which have constraints. I've tried to import new data using the import mode copy: delete all records in destination, repopulate from the source but I get this error: Could not truncate table. Import…
user2932466
  • 163
  • 1
  • 1
  • 9
0
votes
1 answer

Display end of text in UITextField after programmatically appending character

I am programmatically appending text to a UITextField while the keyboard is not on screen (so there is no typing indicator in the field). Once the text fills up the field, it will continue adding text but will not scroll to the end to show the last…
Jordan H
  • 52,571
  • 37
  • 201
  • 351