mysql jdbc: what is column size for BIGINT?
jdbc:
id BIGINT(20)
ResultSet columns = databaseMetaData.getColumns("foo", "bar", "table", "id");
columns.next();
int columnSize = columns.getInt(7);
Q: What is column size for BIGINT?
The MySQL BIGINT
datatype is a 64-byte signed integer. From a JDBC resultset, that can be handled in Java as a long
.
With the unsigned variant, the MySQL BIGINT UNSIGNED
dataype, that could be handled as java.math.BigInteger
. (The maximum value of MySQL BIGINT UNSIGNED
exceeds the maximum value of Java long
.)
Q: Is it 19 bytes?
The longest string value that MySQL will return for a BIGINT would be '-9223372036854775808'
, which is 20 characters. (An extra character is required for the minus sign.)
For a BIGINT UNSIGNED
, the longest string value that MySQL will return in a resultset would be 19 characters.
In terms of storage in the MySQL database, the BIGINT datatype requires eight bytes.