错误:关系列PostgreSQL不存在,无法运行插入查询 [英] ERROR: column of relation does not exist PostgreSQL ,Unable to run insert query
问题描述
我正在尝试插入表tester3中,当我使用语法
Hi I am trying to insert into a table tester3 it fails when i use the syntax
insert into tester3 (UN0, UN1) values ( 1, 'jishnu1');
但是
insert into tester3 values ( 1, 'jishnu1');
工作正常。
mydb=# CREATE TABLE tester3
mydb-# (
mydb(# "UN0" integer,
mydb(# "UN1" VARCHAR(40)
mydb(# );
CREATE TABLE
mydb=# insert into tester3 (UN0, UN1) values ( 1, 'jishnu1');
ERROR: column "un0" of relation "tester3" does not exist
mydb=# \d tester3
Table "public.tester3"
Column | Type | Modifiers
--------+-----------------------+-----------
UN0 | integer |
UN1 | character varying(40) |
我想我错过了一些琐碎的事情,我尝试了其他一些列名,其中一些还不错
I think i am missing something very trivial, I tried someother column names some of them works fine and some are not working. I am confused. Does PostgreSQL have restriction in column names for which works the 1st syntax of insert query works?
编辑:
结帐Girdon Linoff答案并为弗兰克·海肯斯指出了其他在不加引号的情况下使用的列名,在小写中。
Checkout Girdon Linoff answer and as Frank Heikens pointed out the other column names which was working without quotes where in lower case.
小写列是PostgreSQL中的标准,也可以不使用引号
Lower case column is the standard within PostgreSQL and also works without quotes
推荐答案
如果用双引号定义列,那么在引用该列时通常需要使用它们:
If you define the columns with double quotes, then you generally need to use them when you refer to the column:
insert into tester3 ("UN0", "UN1")
values ( 1, 'jishnu1');
我建议您从 CREATE中的列名称中删除双引号TABLE
语句。
如果名称全部为小写,则不需要双引号。
You don't need the double quotes if the name is all lower case.
这篇关于错误:关系列PostgreSQL不存在,无法运行插入查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!