【发布时间】:2014-08-16 11:32:06
【问题描述】:
和题目说的差不多。
truncate table "Account" restart identity cascade;
insert into "Account" ("name", "enabled") values ("test", 1);
select * from "Account";
输出:
accountId | name | enabled
-----------+------+---------
14 | test | 1
(1 row)
这是表的架构:
Table "public.Account"
Column | Type | Modifiers
-----------+------------------------+---------------------------------------------------------------
accountId | integer | not null default nextval('"Account_accountId_seq"'::regclass)
name | character varying(255) | not null
enabled | integer | not null
Indexes:
"Account_pkey" PRIMARY KEY, btree ("accountId")
Referenced by:
TABLE ""AccountPropertyAccess"" CONSTRAINT "AccountPropertyAccess_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("accountId")
TABLE ""User"" CONSTRAINT "User_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("accountId")
这里有一些额外的词,因为堆栈交换认为我没有足够的词,因为我有太多的代码。
【问题讨论】:
-
显示表架构
\d "Account" -
您在第一个代码块中的插入语句无效。字符串文字必须使用单引号
"test"表示列,而不是值。
标签: postgresql