Reputation: 323
I am trying to set the length to infinity of one of the field of my database table whose data type is integer (BIGINT). Kindly let me know how can I set the length of the field to infinity/unlimited?
Column Type Collation Attributes Null Default Extra Action 1 id bigint(255) No None AUTO_INCREMENT
Upvotes: 1
Views: 2636
Reputation: 92805
For maximum values take a look at documentation
BIGINT SIGNED - 9223372036854775807
BIGINT UNSIGNED - 18446744073709551615
mysql> CREATE TABLE Table1(`col1` BIGINT, `col2` BIGINT UNSIGNED); Query OK, 0 rows affected (0.02 sec) mysql> DESC table1; +-------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------------------+------+-----+---------+-------+ | col1 | bigint(20) | YES | | NULL | | | col2 | bigint(20) unsigned | YES | | NULL | | +-------+---------------------+------+-----+---------+-------+ 2 rows in set (0.00 sec) mysql> INSERT INTO Table1 VALUES(9223372036854775807, 18446744073709551615); Query OK, 1 row affected (0.00 sec) mysql> SELECT * FROM Table1; +---------------------+----------------------+ | col1 | col2 | +---------------------+----------------------+ | 9223372036854775807 | 18446744073709551615 | +---------------------+----------------------+ 1 row in set (0.00 sec)
Upvotes: 1
Reputation: 416
I think it is not allowed in DBMS, but some DBMS like MSDE 2000 can accept the infinite float value. but it is a fatal error if you save this value.
i mean are sure your application needs such kind of data without having no errors. ?
BIGINT range is:
-9223372036854775808 to 9223372036854775807 normal. 0 to 18446744073709551615 UNSIGNED*.
The maximum number of digits may be specified in parenthesis
if you query this infinite OR NaN data , your DB may corrupt or throw a fatal error. That is why it is recommned to better use Exceptional handling before querying if you have no idea about the stored data.
Upvotes: 0
Reputation: 799082
You cannot. All *INT
fields have a fixed length that directly relates to the size of integers in various programming languages (and in particular, C). Even DECIMAL
has a maximum size. If you need larger than it provides then use one of the *TEXT
fields to hold the value as a string, but be aware that even those have limitations.
Upvotes: 2