PostgreSQL is a popular open-source relational database management system that supports various data types, including
bigint is an integer data type provided by PostgreSQL that is typically used to store integers that exceed the range of standard integer types.
bigint data type can store integers in the range of -9223372036854775808 to 9223372036854775807. To declare a column with the
bigint type in a table, you can use the following syntax:
In general, standard integer types can be used to store integers that need to be stored. However, if you need to store very large integers, you can use the
bigint type. For example, when dealing with large datasets, you may need to use the
Example 1: Creating a table with a
Here is an example of a table that includes a column with the
CREATE TABLE mytable (
id serial PRIMARY KEY,
Example 2: Performing calculations with
You can perform regular arithmetic operations, such as addition and multiplication, using the
bigint type. Here is an example query that calculates the product of two numbers using the
SELECT 1234567890123456789::bigint * 9876543210987654321::bigint;
The result of the query is:
bigint data type is a useful tool for storing integers that exceed the range of standard integer types. It is particularly useful when you need to store very large integers.