Skip to main content

Questions tagged [integer]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4 votes
3 answers
2k views

Integer number in the 700000s as the days from year 1: how can this be cast in tsql to a date and back if the oldest datetime date is 1753-01-01?

I fell upon an integer format for dates for which I also know the date, but I do not know how to get to that date in TSQL and I also do not know how to get to the integer if I have the date: 700444 -&...
questionto42's user avatar
0 votes
1 answer
1k views

SET BIGINT fieldname value to 0 automatically if inserting empty string

How do I do something like : INSERT INTO tablename SET customer_id = '' WHERE <condition>; customer_id is BIGINT NULL Default NULL But when I execute SET customer_id = '' it gives Incorrect ...
anjanesh's user avatar
  • 279
0 votes
1 answer
174 views

Why isn't it trivial to create a virtual integer timestamp column from a TIMESTAMP column in MySQL?

There's no way to extract an integer timestamp from a TIMESTAMP column in a virtual column context in MySQL because UNIX_TIMESTAMP is not allowed in virtual columns. Why isn't this a trivial task?
Dan's user avatar
  • 235
0 votes
1 answer
2k views

How to subtract from the current timestamp the number of hours stored in a column?

I am trying to retrieve data from a column with integer values by getting the difference between the current_timestamp and the values in the column. This works in DB2 by simply stating the value as ...
kunleoju's user avatar
1 vote
1 answer
268 views

Check int4range includes number using B-tree index

I have a table with two important columns: value and m_range, where value: CREATE TABLE m_filter ( value BIGINT NOT NULL, m_range ...
g4s8's user avatar
  • 111
2 votes
2 answers
320 views

Compare signed integers as if they were unsigned

I am using PostgreSQL to store 64 bits IDs. The IDs are unsigned and make full use of all their bits (including the first one). To store said IDs, I am currently converting them to signed integers ...
Sadiinso's user avatar
  • 123
0 votes
0 answers
37 views

Getting the max ID of integer columns in databases in Postgres 9.6/12

I am looking to get the max ID of each integer column in our databases servers. The function I currently use: CREATE OR REPLACE FUNCTION intpkmax() RETURNS TABLE(schema_name name, table_name name, ...
rdbmsNoob's user avatar
  • 459
0 votes
1 answer
1k views

Calculating Average Value of JSONB array in Postgres

I have a column called "value" in my "answers" table. | value | |---------| | [1,2] | | [1] | | [1,2,3] | The type of "value" is "jsonb". I want to get ...
user avatar
1 vote
2 answers
521 views

How to make MySQL 8 alert when integer overflow happens during INSERT ... ON DUPLICATE KEY?

Let's consider we have a simple table with auto-incrementing integer ID and some unique column: CREATE TABLE `test` ( `id` int unsigned NOT NULL AUTO_INCREMENT, `value` tinyint DEFAULT NULL, ...
Stalinko's user avatar
  • 191
5 votes
1 answer
2k views

Will SQL Server "int" datatype reliably truncate (and not round) decimal values when they are input?

I have a user with software that sometimes sends back a UNIT's ID as an integer(ex. 1000), and sometimes with a small decimal value appended (ex. 1000.001). The software automatically generates MSSQL ...
Brett Walters's user avatar
2 votes
2 answers
357 views

How does Postgres handle integer data of different sizes in the same column?

If I have a bigint column and in one row store 1 and in another store 999999999999, will these take up different amounts of space on disk? Will Postgres have an easier time doing queries and ...
John Bachir's user avatar
7 votes
1 answer
740 views

Are there any reasons to not use smallint when it fits the data?

Since PostgreSQL doesn't have 1-byte tinyint, the second best option would be smallint. However, I've read from various posts that it may actually be slower because CPU's are optimized to operate on ...
davidtgq's user avatar
  • 749
9 votes
3 answers
18k views

How to import blanks as nulls instead of zeros while importing txt using wizard

I'm using the Import Wizard to load a text file and need blanks in integer fields to be nulls, but only zeros are inserted. How to import it properly?
Vladimir's user avatar
13 votes
1 answer
18k views

Text string stored in SQLite Integer column?

I'm a database novice looking at an SQLite database which appears to be storing text in an integer column. Here's an example session at the sqlite3 command line: sqlite> .schema mytable CREATE ...
igal's user avatar
  • 345
0 votes
1 answer
459 views

Numeric Latitude & Longitude values are rounded up when querying SQL Server Database

Developing an application that is using Google Maps. Latitude and longitude values are stored in the table as the correct value. However when they are pulled into a view the value is rounded to the ...
rwatts's user avatar
  • 131
0 votes
1 answer
5k views

Do I lose data if I change from INT to TINYINT

I have a database (Engine InnoDB) that was setup by someone else. I noticed that one column contains data between 1 and 107 at this moment, and it is highly unlikely to further increase much. As it ...
Kolja's user avatar
  • 363
5 votes
1 answer
2k views

Rounding issues?

Try this: create table test (f float); insert into test values (330.0); commit; select (8 + 330.0/60)::int; --14 select (8 + f/60)::int from test; --14 select (9 + 330.0/60)::int; --15 select (9 + f/...
kev's user avatar
  • 397
0 votes
1 answer
7k views

Looping through string, adding all numbers e.g. '123' = 1+2+3, demo with working loop included

This works to output the string 123456 as: 1 2 3 4 5 6 Code: declare @string varchar(20) declare @index int declare @len int declare @char char(1) set @string = '123456' set @index = 1 set @len= ...
Peter PitLock's user avatar
1 vote
1 answer
3k views

Should I be concered by large SERIAL values?

I have a Django application that uses PostgreSQL to analyze data from tweets. The data set increases by thousands of records with each request. I am using the database primarily as a cache, so I had ...
Sean W.'s user avatar
  • 125
1 vote
1 answer
126 views

Expanding contractions/number ranges into separate records [closed]

I am planning the migration of a directory of image files plus a FileMaker-database containing the corresponding metadata into an Imagic IMS database (formerly known as ImageAccess). The vendor ...
Oliver's user avatar
  • 19