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。我现在觉得很愚蠢。 –