Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between BIGINT and INT8? (postgres)

Tags:

postgresql

I'm using a service called Supabase and I created a table:

CREATE TABLE my_table ( 
    "id" BIGSERIAL PRIMARY KEY NOT NULL,
    "title" Text COLLATE "pg_catalog"."default",
    "message" Text COLLATE "pg_catalog"."default");

However, this turns into an int8 type. Is that smaller than bigint?

like image 940
user1354934 Avatar asked Sep 13 '25 08:09

user1354934


1 Answers

BIGINT is just an alias for INT8 in PostgreSQL. Try this:

CREATE TABLE t (
  c1 bigint,
  c2 int8
);

SELECT a.attname, t.typname
FROM pg_class AS c 
JOIN pg_attribute AS a ON a.attrelid = c.oid
JOIN pg_type AS t ON a.atttypid = t.oid
WHERE c.relname = 't'
AND a.attname IN ('c1', 'c2')
ORDER BY 1;

You'll get:

|attname|typname|
|-------|-------|
|c1     |int8   |
|c2     |int8   |

There's no stored type name bigint in pg_type:

SELECT * FROM pg_type WHERE typname IN ('int8', 'bigint');

This only returns:

|typname|
|-------|
|int8   |
like image 64
Lukas Eder Avatar answered Sep 15 '25 00:09

Lukas Eder