Postgresql PSQL序列盯着看。为什么这不能完成?

时间:2010-03-08 18:51:57

标签: sql postgresql

我在psql中试图为python管理员创建一个表。它实际上是一个工作管理员的扩展,所以我添加了一个新表和一些关系。当我按以下顺序输入时,它永远不会执行完成:

BEGIN;

   CREATE TABLE "work_projectinteractiveasset" (
     "id" serial NOT NULL PRIMARY KEY,
     "name" varchar(200) NOT NULL,
     "image" varchar(100) NOT NULL,
     "project_id" integer NOT NULL REFERENCES "work_project" ("id") DEFERRABLE INITIALLY DEFERRED
   );

    CREATE INDEX "work_projectinteractiveasset_project_id" 
        ON "work_projectinteractiveasset" ("project_id");

COMMIT;

提示以

结尾
  

注意:CREATE TABLE将为串行列“work_projectinteractiveasset.id”创建隐式序列“work_projectinteractiveasset_id_seq”

但它只是停留在那里直到我ctrl-c出来。有没有办法强制完成?

1 个答案:

答案 0 :(得分:3)

我实际上无法产生此错误。然而,它听起来像是一个阻止工作完成的锁。

 postgres=# create table work_project (id int primary key);
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "work_project_pkey" for table "work_project"
CREATE TABLE
postgres=# BEGIN;
BEGIN
postgres=# 
postgres=#    CREATE TABLE "work_projectinteractiveasset" (
postgres(#      "id" serial NOT NULL PRIMARY KEY,
postgres(#      "name" varchar(200) NOT NULL,
postgres(#      "image" varchar(100) NOT NULL,
postgres(#      "project_id" integer NOT NULL REFERENCES "work_project" ("id") DEFERRABLE INITIALLY DEFERRED
postgres(#    );
NOTICE:  CREATE TABLE will create implicit sequence "work_projectinteractiveasset_id_seq" for serial column "work_projectinteractiveasset.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "work_projectinteractiveasset_pkey" for table "work_projectinteractiveasset"
CREATE TABLE
postgres=# 
postgres=#     CREATE INDEX "work_projectinteractiveasset_project_id" 
postgres-#         ON "work_projectinteractiveasset" ("project_id");
CREATE INDEX
postgres=# 
postgres=# COMMIT;
COMMIT

postgres =#select version();

版本

x86_64-pc-linux-gnu上的PostgreSQL 8.3.8,由GCC编译gcc-4.4.real(Ubuntu 4.4.1-3ubuntu3)4.4.1 (1排)