错误:postgresql 中不存在用于更新的列 [英] Error: Column does not exist in postgresql for update

查看:85
本文介绍了错误:postgresql 中不存在用于更新的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一行文本插入到该列为空的列中.下面列出了错误.非常感谢任何帮助

I am trying to insert a line of text into a column where that column is null. Error listed below. Any help is greatly appreciated

UPDATE public.meditech_ar_test4
SET filename = "text"
WHERE filename is null;

错误:列文本"不存在:我知道该列不存在,我想将其插入到字段中

ERROR: column "text" does not exist: I am aware that column does not exist, I want to insert it into the field

推荐答案

在 Postgres 中,双引号代表标识符(例如表名或列名).在这里,您实际上想要一个字符串文字,因此您需要单引号:

In Postgres, double quote stand for identifiers (such as table or column names). Here, you actually want a string literal, so you need single quotes:

UPDATE public.meditech_ar_test4
SET filename = 'text'
WHERE filename is null;

某些数据库(即 MySQL)允许字符串文字使用双引号,而使用其他字符作为标识符(在 MySQL 中:反引号).然而,在这方面 Postgres 遵循标准 SQL 的规则,它为标识符定义双引号.您应该养成始终对字符串文字使用单引号的习惯(大多数数据库都支持).

Some databases (namely, MySQL), tolerate double quotes for string literals, while using other characters for identifiers (in MySQL: backticks). However in that regard Postgres follows the rules of standard SQL, which defines double quotes for identifiers. You should just take the habit of always using single quotes for string literals (most databases do support that).

这篇关于错误:postgresql 中不存在用于更新的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆