0
我很難將簡單的數據輸入到postgres表中。將數據輸入到PostgreSQL時發生問題
這裏的表:
user=# \d main_attribute_types;
Column | Type | Modifiers
------------+-----------------------+-------------------------------------------------------------------
id | integer | not null default nextval('main_attribute_types_id_seq'::regclass)
name | character varying(16) | not null
field_name | character varying(16) | not null
Indexes:
"main_attribute_types_pkey" PRIMARY KEY, btree (id)
Referenced by:
TABLE "main_additional_attributes" CONSTRAINT "main_addi_attribute_type_id_1cb89d3d_fk_main_attribute_types_id" FOREIGN KEY (attribute_type_id) REFERENCES main_attribute_types(id) DEFERRABLE INITIALLY DEFERRED
我嘗試的命令:
INSERT INTO main_attribute_types (NULL, "Integer", "IntegerField");
INSERT INTO main_attribute_types (1, "Integer", "IntegerField);
INSERT INTO main_attribute_types (id, name, field_name) VALUES (NULL, "Integer", "IntegerField");
INSERT INTO main_attribute_types (name, field_name) VALUES ("Integer", "IntegerField");
而每一次我得到一個錯誤:
ERROR: column "Integer" does not exist
LINE 1: INSERT INTO main_attribute_types VALUES (1, "Integer", "Inte...
^
這excatly如何做到這一點官方相關文件: https://www.postgresql.org/docs/9.0/static/dml-insert.html
我的Postgres版本是9.3.13
我絕對不知道爲什麼它不工作。
字符串需要使用單引號,而不是雙引號。就像在文檔中一樣。 –
不,它在文檔中不是**。文檔使用單引號,而不是雙引號。 'INSERT INTO main_attribute_types(NULL,'Integer','IntegerField');' –
OMG。我現在覺得很愚蠢。 –