insert - Greenplum 日期/时间字段超出范围:“2020 年 10 月 10 日”
问题描述
我正在使用这种形式的表格测试 Greenplum(基于 Postegres):
CREATE TABLE whiteglove (bigint BIGINT,varbinary bytea,boolean BOOLEAN,date DATE,decimal DECIMAL,double float,real REAL,integer INTEGER,smallint SMALLINT,timestamp TIMESTAMP,tinyint smallint,varchar VARCHAR)
然后我尝试使用 Postegres JDBC 驱动程序插入这一行
INSERT INTO whiteglove VALUES (100000,'68656c6c6f',TRUE,'10/10/2020',0.5,1.234567,1.234,10,2,'4/14/2015 7:32:33PM',2,'hello')
失败并出现以下错误
org.postgresql.util.PSQLException: ERROR: date/time field value out of range: "10/10/2020"
Hint: Perhaps you need a different "datestyle" setting.
Position: 57
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:312)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:310)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:296)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:273)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:268)
如果我采用相同的查询并使用 psql 从终端执行它,它会毫无问题地通过
dev=# select * from whiteglove ;
bigint | varbinary | boolean | date | decimal | double | real | integer | smallint | timestamp | tinyint | varchar
--------+-----------+---------+------+---------+--------+------+---------+----------+-----------+---------+---------
(0 rows)
dev=# INSERT INTO whiteglove VALUES (100000,'68656c6c6f',TRUE,'10/10/2020',0.5,1.234567,1.234,10,2,'4/14/2015 7:32:33PM',2,'hello');
INSERT 0 1
dev=# select * from whiteglove ;
bigint | varbinary | boolean | date | decimal | double | real | integer | smallint | timestamp | tinyint | varchar
--------+------------+---------+------------+---------+----------+-------+---------+----------+---------------------+---------+---------
100000 | 68656c6c6f | t | 2020-10-10 | 0.5 | 1.234567 | 1.234 | 10 | 2 | 2015-04-14 19:32:33 | 2 | hello
(1 row)
关于我为什么会出现超出范围错误的任何指示?
解决方案
推荐阅读
- java - 如何在 PHP 中解码 Java 流
- r - 在 R 的 ggplot 中使用 stat_ecdf
- jquery - Not able to click/select element using JQuery in Laravel Dusk
- javascript - Is there a way to run a line of code after a marquee has finished scrolling once?
- highcharts - Combined Chart Highcharts Pie plus Bar grouppadding and pointapadding issue
- javascript - 为什么函数返回未定义?
- java - 无法在 CentOS 7 上执行 java 程序
- python - 在 Python 中更改颜色映射上的数字大小
- docker - Docker cli:带有引用参数的 docker run 命令
- spring-boot - 我们可以更改 Azure 广告中的 Redirect_uri