Skip to main content

PostgreSQL 时间类型

MarshioLess than 1 minutepostgresql

官网 datetime 介绍open in new window

首先,postgre 并没有 datetime 类型,只有如下这些类型。

NameStorage SizeDescriptionLow ValueHigh ValueResolution
timestamp [ (*p*) ] [ without time zone ]8 bytesboth date and time (no time zone)4713 BC294276 AD1 microsecond
timestamp [ (*p*) ] with time zone8 bytesboth date and time, with time zone4713 BC294276 AD1 microsecond
date4 bytesdate (no time of day)4713 BC5874897 AD1 day
time [ (*p*) ] [ without time zone ]8 bytestime of day (no date)00:00:0024:00:001 microsecond
time [ (*p*) ] with time zone12 bytestime of day (no date), with time zone00:00:00+155924:00:00-15591 microsecond
interval [ *fields* ] [ (*p*) ]16 bytestime interval-178000000 years178000000 years1 microsecond

在 python 的 SQLAlchemy 框架中,DATETIME 类型对应 PostgreSQLtimestamp without time zone