Answer a question

I am trying to map the java type to the SQL type and I encountered such a scenario.

If I elaborate, I was using the auto-ddl api to apply scripts to my database while starting my spring container. Now I am trying to generate the scripts using liquibase by generating the db-changelog for POSTGRE server.

Are numeric(19,0) and BIGINT same in Postgres server? Please put some light on this.

Answers

BIGINT range is -9223372036854775808 to 9223372036854775807, so you can't store a number greater than 9223372036854775807, but NUMERIC (19, 0) can do.

Please find the following example:

CREATE TABLE TestTable (NumVal NUMERIC (19,0), IntVal BIGINT);

INSERT INTO TestTable (NumVal, IntVal) VALUES
('9223372036854775808', 9223372036854775807);

SELECT * FROM TestTable;

Here you can't store 9223372036854775808 in to BIGINT, but you can store the same value or greater than the value to NUMERIC (19, 0)

db<>fiddle for the same.

Logo

PostgreSQL社区为您提供最前沿的新闻资讯和知识内容

更多推荐