Column column of type timestamp without milliseconds?

I want to create a table (id, time) and time (timestamp without timezone) without milliseconds.
And I also want to insert the current default time.

CREATE TABLE ddd (
    id          serial not null,         
    time        timestamp without time zone default now()
    );
+4
source share
1 answer

Indicate accuracy:

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)

A small note - "time"is a bad name for a table field (I understand this is an example). Any field name must have specific semantics.

+12
source

All Articles