问题描述
我应该更新一行的值,但列名有点。
我尝试了 name.name
但什么也没有,尽管它似乎在 MysqL 上工作。
如何使用 postgresql?我发誓,在创建此线程之前,我已经搜索了所有内容。
谢谢
更新: 感谢您的快速回答,我尝试使用“”,但结果是
ERROR: column "name.name" of relation "my_table" does not exist
我的查询:
update my_table set "name.name"='a081613e-2e28-4cae-9ff7-4eaa9c918352';
解决方法
用双引号将名称括起来:"name.name"
更新:
更新:感谢您的快速回答,我尝试使用“”,但结果是这样
你确定这是你的情况吗?
psql (13.2)
Type "help" for help.
postgres=# CREATE DATABASE example_db;
CREATE DATABASE
postgres=# \c example_db
You are now connected to database "example_db" as user "postgres".
example_db=# CREATE TABLE example_table ("example.field" int);
CREATE TABLE
example_db=# \d example_table
Table "public.example_table"
Column | Type | Collation | Nullable | Default
---------------+---------+-----------+----------+---------
example.field | integer | | |
example_db=# SELECT "example.field" FROM example_table;
example.field
---------------
(0 rows)
example_db=# SELECT "example_table"."example.field" FROM example_table;
example.field
---------------
(0 rows)
example_db=#
,
您可以在列名周围使用 ""