我对PostgreSQL完全不熟悉。我有一个包含下一列的表格:
db_1=# select * from table1 where false;
id | createdat | description | index | name | updatedat | type_id |dtype
----+-----------+-------------+-------+------+-----------+---------+-----
(0 rows)
内容如下:
db_1=# select id,name,dtype from table1;
id | name | dtype
---+---------+--------------
1 | name1 | PlantControl
2 | name2 | PlantSystem
3 | name3 | PlantControl
4 | name4 | PlantControl
5 | name5 | PlantSystem
6 | name6 | AlarmSystem
7 | name7 | AlarmSystem
(7rows)
如果我尝试使用dtype=PlantSystem
删除每一行,则会出现下一个错误:
db_1=# delete from table1 where dtype=PlantControl; ERROR: column "plantcontrol" does not exist LINE 1: delete from table1 where dtype=PlantControl;
显然,PlantControl
不是列,列是dtype
...
答案 0 :(得分:3)
您需要引用PlantControl值。
delete from table1 where dtype='PlantControl';