I want to create a table have(id,time) and time (timestamp without timezone) without milliseconds.
And I also want to insert the current time per default.
CREATE TABLE ddd (
id serial not null,
time timestamp without time zone default now()
);
Specify a precision:
postgres=# CREATE TABLE foo(a timestamp(0));
CREATE TABLE
postgres=# INSERT INTO foo VALUES(CURRENT_TIMESTAMP);
INSERT 0 1
postgres=# SELECT * FROM foo;
a
---------------------
2014-01-02 07:26:23
(1 row)
Small note - "time"
is a bad name for table field (I understand this is example). Any field name should have a specific semantic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With