【发布时间】:2013-11-08 00:01:11
【问题描述】:
我按照 postgres 文档中注释的说明将日志创建为 CSV 格式,然后在数据库中创建一个带有相应字段的表 (http://www.postgresql.org/docs/9.0/static/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSVLOG)
CSV 的内容如下所示:
2013-11-07 23:07:31.524 CET,"postgres","postgres",5556,"::1:62188",527c0f1e.15b4,1,"idle",2013-11-07 23:07:26 CET,2/23,0,LOG,00000,"sentencia: DROP TABLE public.mytable",,,,,,,,,"pgAdmin III - Browser"
但是当我执行 COPY 指令时:
COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
发生错误,说time zone类型的语法无效:
ERROR: la sintaxis de entrada no es válida para tipo timestamp with time zone: «2013-11-07 23:04:59.124 CET»
CONTEXT: COPY postgreslog, línea 1, columna log_time: «2013-11-07 23:04:59.124 CET»
********** Error **********
ERROR: la sintaxis de entrada no es válida para tipo timestamp with time zone: «2013-11-07 23:04:59.124 CET»
SQL state: 22007
Context: COPY postgreslog, línea 1, columna log_time: «2013-11-07 23:04:59.124 CET»
如果我使用例如 PgAdminIII 直接插入注册表,并且我将“log_time”列的值设置为“2013-11-07 23:07:31.524 CET”,则它被正确插入。
有人知道发生了什么吗?
非常感谢。
【问题讨论】:
-
这有效:插入 postgreslog (log_time, session_id, session_line_num) values('2013-11-07 23:04:59.124 CET', 'a', 1);
-
你的表是如何创建的?
标签: sql postgresql logging csv copy