Updating a PostgreSQL column that contains dot (.) in its name

1.7k views Asked by At

I should update the value of a row, but the column name has the dot.

I tried name.name but nothing, even though it seems to work on MySQL.

How can I do with postgresql? I swear that before creating this thread I searched all over.

Thanks

UPDATE: Thanks for the quick answers, I tried to use "" but this is the result

ERROR:  column "name.name" of relation "my_table" does not exist

My query:

update my_table set "name.name"='a081613e-2e28-4cae-9ff7-4eaa9c918352';
2

There are 2 answers

0
M. Dudek On BEST ANSWER

You can use "" around the column name

0
madbird On

Wrap name with double quotation marks: "name.name"

UPD:

UPDATE: Thanks for the quick answers, I tried to use "" but this is the result

Are you sure then that it's your case?

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=#