PostgreSQL脚本引用挂起

时间:2017-02-10 07:22:38

标签: postgresql ddl

我是PostgreSQL的新手,我正在努力解决DDL问题。除非我从表和唯一约束定义中删除列“龙骨”,否则脚本“挂起”。可能是什么错误?您的输入非常受欢迎。

CREATE TABLE k_keel
(
  id integer NOT NULL,
  nim character varying(30) NOT NULL,
  kood character(2) NOT NULL, -- Kahetäheline ISO 639 keelekood
  CONSTRAINT k_keel_pkey PRIMARY KEY (id),
  CONSTRAINT k_keel_nim_uniq UNIQUE (nim)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE k_keel
  OWNER TO postgres;
GRANT ALL ON TABLE k_keel TO postgres;
GRANT SELECT ON TABLE k_keel TO overload;
COMMENT ON COLUMN k_keel.kood IS 'Kahetäheline ISO 639 keelekood';

-- Table: ac.e_kiri

-- DROP TABLE ac.e_kiri CASCADE;

CREATE TABLE ac.e_kiri
(
  id INTEGER PRIMARY KEY DEFAULT nextval('ac.email_id_seq'::regclass),
  nimi character varying(100) NOT NULL UNIQUE,
  memo TEXT
)
WITH (
  OIDS=FALSE
);
ALTER TABLE ONLY ac.e_kiri
    ADD CONSTRAINT "Nimi peal olema unikaalne" UNIQUE (nimi);
ALTER TABLE ac.e_kiri
  OWNER TO postgres;
GRANT ALL ON TABLE ac.e_kiri TO postgres;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE ac.e_kiri TO overload;
COMMENT ON TABLE ac.e_kiri IS 'Tüüpkirjade tabel';

-- DROP  TABLE ac.e_kiri_tekst CASCADE;

CREATE TABLE ac.e_kiri_tekst
(
  id INTEGER PRIMARY KEY DEFAULT nextval('ac.email_id_seq'::regclass),
  e_kiri INTEGER REFERENCES ac.e_kiri (id) NOT NULL,
  keel INTEGER REFERENCES public.k_keel (id) NOT NULL,
  subjekt text,
  sisu text
)
WITH (
  OIDS=FALSE
);
ALTER TABLE ONLY ac.e_kiri_tekst
    ADD CONSTRAINT "Nimi ja keel peavad olema unikaalsed" UNIQUE (e_kiri,keel);
ALTER TABLE ac.e_kiri_tekst
  OWNER TO postgres;
GRANT ALL ON TABLE ac.e_kiri_tekst TO postgres;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE ac.e_kiri_tekst TO overload;
COMMENT ON TABLE ac.e_kiri_tekst IS 'Tüüpkirja subjekt ja tekst antud keeles'; 

0 个答案:

没有答案