Javatpoint Logo
Javatpoint Logo

PostgreSQL BIGINT

In this section, we are going to understand the working of the PostgreSQL Bigint data type. And we also see examples of the bigint data type.

What is PostgreSQL Bigint Data Type?

In PostgreSQL, the next integer data type that we are going to understand is BIGINT.

The BIGINT data types are large-range integers, which involve 8 bytes of storage size and store integers in the signed range and unsigned range.

And the Signed range starts from -9223372036854775808 to 9223372036854775807. And the unsigned range began with 0 to 18446744073709551615. The size parameter is used to define the maximum display width that is 255.

Note: PostgreSQL does not allow us to use the unsigned integer types.

Generally, the BIGINT data type is used to store a vast range of records such as the scientific constants, the number of stars in a galaxy, etc.

Note:

  • Generally, we do not prefer to use the Bigint data type as it takes lots of storage and reducing the performance of the database server.
  • However, if the integer values might surpass the range given by the int or integer data type, then only we go for the PostgreSQL bigint data type as it is an extensive range of integer.

Syntax of PostgreSQL BIGINT data type

The syntax of the PostgreSQL BIGINT data type is as follows:

Examples of PostgreSQL BIGINT data type

Let us see different examples to understand how the PostgreSQL BIGINT data type works.

We are creating one new table with the CREATE command's help and inserting some values using the INSERT command.

In the following example, we will create Fundamental_constants into a javatpoint database by using the CREATE command to store the values of serval scientific fundaments constants.

Output

After executing the above command, we will get the below message: The Fundamental_constants table has been successfully created, as shown in the below screenshot:

PostgreSQL BIGINT

Once the table Fundamental_constants has been generated, we can insert some values into it using the INSERT command.

Output

After executing the above command, we will get the below message: the particular value has been inserted successfully in the Fundamental_constants table.

PostgreSQL BIGINT

As we can see in the above screenshot, the multiple values have been inserted successfully into the Fundamental_constants table.

After creating and inserting the Fundamental_constants table's values, we will use the SELECT command to return all rows of the Fundamental_constants table:

Output

After successfully implementing the above command, we will get the below output:

PostgreSQL BIGINT

Example2

Let us see one more example to learn the Bigint data type in detail.

So, we are going to create another new table as Solar_system table with the help of CREATE command into a similar database that is javatpoint to store the numbers of stars in several solar system or galaxies:

Output

The Solar_system table has been successfully created after executing the above commands, as shown in the below screenshot:

PostgreSQL BIGINT

Once the Solar_system table has been generated, we will insert some values into it using the INSERT command as shown in the below command:

Output

We will get the following message on implementing the above command: the value has been inserted successfully into the Solar_system table.

PostgreSQL BIGINT

After creating and inserting the strong>Solar_system table's values, we will use the SELECT command to return all rows of the strong>Solar_system table:

Output

After implementing the above command, we will get the following output as shown in the below screenshot:

PostgreSQL BIGINT

Overview

In the PostgreSQL Bigint data type section, we have learned that it stores only an extensive range of records such as the number of stars in the solar system, constants.


Next TopicPostgreSQL Serial




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA