I have a column in PostgresSQL table that is defined as (_date). I am using DBeaver application. When I looked up the data type it says date[] which I think it’s an array. I am trying to create a similar table but unsure how to define that field column. Any suggestions please. Below the code I am using to get the data type of this field -
Select pg_typeof(“column_name”) from table_name limit 1
The above query returns date[]
Thanks
_date is only a synonym for date[]
with both you can insert dates like
CREATE tABLE test(dte_n _date)
CREATE TABLE
CREATE tABLE test1(dte_n date[])
CREATE TABLE
INSERT INTO test VALUES ('{2023_01_01}')
INSERT 0 1
INSERT INTO test1 VALUES ('{2023_01_01}')
INSERT 0 1
INSERT INTO test1 VALUES ('{2023_01_01,2023-02-02}')
INSERT 0 1
Select pg_typeof(dte_n) from test limit 1
pg_typeof |
---|
date[] |
SELECT 1
Select pg_typeof(dte_n) from test1 limit 1
pg_typeof |
---|
date[] |
SELECT 1