Postgres: support for timestamp precision
See original GitHub issueDBeaver currently does not support setting precision for timestamp columns. Additionally, it creates incorrect DDL code for tables that contain timestamp columns with precision other than default.
For example, I have a table like this:
CREATE TABLE public.dates
(
id integer NOT NULL,
ts timestamp without time zone,
ts0 timestamp(0) without time zone,
ts1 timestamp(1) without time zone,
ts6 timestamp(6) without time zone,
CONSTRAINT dates_pk PRIMARY KEY (id)
)
DBeaver creates this DDL for the table:
CREATE TABLE public.dates (
id int4 NOT NULL,
ts timestamp NULL,
ts0 timestamp NULL,
ts1 timestamp NULL,
ts6 timestamp NULL,
CONSTRAINT dates_pk PRIMARY KEY (id)
);
As you can see the precision definitions are lost. Precision can be seen in the Columns tab of a table in the Scale column - it can even be edited but DBeaver fails to create correct DDL when trying to persist the changes, it always lacks any precision definition:
ALTER TABLE public.dates ALTER COLUMN ts6 TYPE timestamp USING ts6::timestamp;
I think we would need support for precision in timestamp columns. As far as I can see there is no practical difference between timestamp
and timestamp(6)
columns but Postgres keeps the distinction in the table definition nevertheless and it would be good if DBeaver also did that.
I think the same issue applies to time
and interval
data types since they also accept precision parameter - but I haven’t done any tests on them.
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (13 by maintainers)
Top GitHub Comments
DDL changed for data types timestamp… and for time. 6 set as default (not shown)
@LonwoLonwo that’s is exactly my point. Somehow, the precision parameter for timestamp ended up in “Scale”. I will create the new ticket.
Thanks again.