postgresql - 如何使用 now () 和 \copy from 命令更新我的 postgres 数据库中名为 created_on 的列的当前时间
问题描述
我正在将csv
文件从本地加载psql
到postgres
使用\copy
. 问题是,created_on
每当记录更新但 created_on 具有没有时区类型且具有非空约束的时间戳时,就有一个称为它需要更新到系统时间的列。那么如何在一个语句中加载csv
文件并同时将其设置为 now 呢?created_on
\copy counter_template(counter_name,category,counter_type_name,module_name,default_instance_name,query_string,execution_type,user_id,enterprise_id,created_by,display_name,unit) from 'F:\Work\test2.csv' with delimiter as ',' FORCE NOT NULL default_instance_name,query_string,execution_type HEADER csv;
错误:
ERROR: null value in column "created_on" violates not-null constraint
DETAIL: Failing row contains (5470, hostname, status, null, Apache_Metricset, null, Application, f, f, null, f, f, 1, , f, , , f, 1, 0, f, null, null, 1, null, Hostname, keyword, f, f, f, 0, , f, null, f, null).
解决方案
推荐阅读
- amazon-web-services - 如何在 AWS Augmented AI 中删除工作任务模板?
- java - javax.crypto.IllegalBlockSizeException:数据不能超过 256 个字节
- c# - 如何调试 Expression.Lambda?(.net core 2.1 和 .net core 3.1 之间表达式树评估的差异)
- python - 更新 Python 3.8 不更新 pip
- java - 如何在 Java 中获取部分用户输入?
- c++ - C ++类如何将右值表达式的结果直接写入左值
- java - 如何使用 Oracle 驱动程序依赖自定义构建 Spring Cloud Data Flow 服务器?
- java - JSQLParser 凝胶查询和子查询中的所有选择项
- javascript - 使用 JS 内部文本插入元素会导致它们被原始打印(未渲染)
- websphere - 带有 IBM 信息数据阶段的 EXCEL 文件