错误:关系列不存在PostgreSQL,无法运行插入查询

前端之家收集整理的这篇文章主要介绍了错误:关系列不存在PostgreSQL,无法运行插入查询前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
嗨我试图插入表tester3它使用语法失败
  1. insert into tester3 (UN0,UN1) values ( 1,'jishnu1');

  1. insert into tester3 values ( 1,'jishnu1');

工作正常.

  1. mydb=# CREATE TABLE tester3
  2. mydb-# (
  3. mydb(# "UN0" integer,mydb(# "UN1" VARCHAR(40)
  4. mydb(# );
  5. CREATE TABLE
  6. mydb=# insert into tester3 (UN0,'jishnu1');
  7. ERROR: column "un0" of relation "tester3" does not exist
  8. mydb=# \d tester3
  9. Table "public.tester3"
  10. Column | Type | Modifiers
  11. --------+-----------------------+-----------
  12. UN0 | integer |
  13. UN1 | character varying(40) |

我想我错过了一些非常微不足道的东西,我尝试了其他一些列名称,其中一些工作正常,一些不起作用.我很迷惑. Postgresql对列名的限制是否适用于插入查询的第一种语法?

编辑:
正如Gordon Linoff所建议的那样使用双引号解决了这个问题.

插入tester3(“UN0”,“UN1”)值(1,’jishnu1′);工作良好

并且正如Frank Heikens所指出的其他列名称在没有引号的情况下工作,其中小写.

Lower case column is the standard within Postgresql and also works without quotes

如果使用双引号定义列,则在引用该列时需要使用它们:
  1. insert into tester3 ("UN0","UN1")
  2. values ( 1,'jishnu1');

我建议你从CREATE TABLE语句中的列名中删除双引号.

猜你在找的Postgre SQL相关文章