2015-11-05 107 views
0
CREATE TABLE sales_invoice -- missing or invalid option 
     (sales_invoice_no     NUMBER(6) NOT NULL 
      CONSTRAINT sales_invoice_no_pk PRIMARY KEY 
     , cust_id       NUMBER(6) NOT NULL 
     , CONSTRAINT sales_cust_invoice_fk FOREIGN KEY (cust_id) 
      REFERENCES customer(cust_id)) 
     , art_id       NUMBER(6) NOT NULL 
     , CONSTRAINT art_invoice_fk FOREIGN KEY (art_id) 
      REFERENCES art_sale(art_id) 
     , sales_emp_id     NUMBER(6) NOT NULL 
     , CONSTRAINT sales_invoice_emp_fk (sales_emp_id) 
      REFERENCES sales_emp(emp_id) 
     , manager_emp_id     NUMBER(6) 
     , CONSTRAINT manager_invoice_emp_fk (manager_emp_id) 
      REFERENCES manager_emp(emp_id) 
     , sales_invoice_amount    NUMBER (10) 
      CONSTRAINT sales_amount_check CHECK (sales_invoice_amount > 0)); 

當我嘗試運行此操作時出現此錯誤。我試圖創建一個表格,從其他幾張表格中抽取出來並作爲銷售發票打印出來。提前致謝。「ORA-00922:缺失或無效的選項」SQL創建表錯誤

+0

我發現一個問題 - 我在sales_emp_id和manager_emp_id之前缺少FOREIGN KEY。但我補充說,仍然失蹤或無效的感染 –

+0

不幸的是,我們真的無法幫助您遠程調試。你還沒有提供足夠的信息... – jpaljasma

回答

0

您的格式就更難察覺,我認爲錯誤。我重新格式化了您的代碼,並在您的「sales_cust_invoice_fk」約束後發現了額外的「)」。這裏是重新格式化的代碼:

CREATE TABLE sales_invoice (
sales_invoice_no NUMBER(6) NOT NULL CONSTRAINT sales_invoice_no_pk PRIMARY KEY 
cust_id   NUMBER(6) NOT NULL, 
art_id   NUMBER(6) NOT NULL, 
sales_emp_id  NUMBER(6) NOT NULL, 
manager_emp_id  NUMBER(6), 
sales_invoice_amount NUMBER (10), 
CONSTRAINT sales_cust_invoice_fk FOREIGN KEY (cust_id) REFERENCES customer(cust_id), 
CONSTRAINT art_invoice_fk FOREIGN KEY (art_id) REFERENCES art_sale(art_id), 
CONSTRAINT sales_invoice_emp_fk (sales_emp_id) REFERENCES sales_emp(emp_id), 
CONSTRAINT manager_invoice_emp_fk (manager_emp_id) REFERENCES manager_emp(emp_id), 
CONSTRAINT sales_amount_check CHECK (sales_invoice_amount > 0) 
); 
+0

謝謝,就是這樣。 –

0

這是查詢

CREATE TABLE sales_invoice 
     (sales_invoice_no     NUMBER(6) NOT NULL 
      CONSTRAINT sales_invoice_no_pk PRIMARY KEY 
     , cust_id       NUMBER(6) NOT NULL 
     , CONSTRAINT sales_cust_invoice_fk FOREIGN KEY (cust_id) 
      REFERENCES customer(cust_id) 
     , art_id       NUMBER(6) NOT NULL 
     , CONSTRAINT art_invoice_fk FOREIGN KEY (art_id) 
      REFERENCES art_sale(art_id) 
     , sales_emp_id     NUMBER(6) NOT NULL 
     , CONSTRAINT sales_invoice_emp_fk FOREIGN KEY (sales_emp_id) 
      REFERENCES sales_emp(emp_id) 
     , manager_emp_id     NUMBER(6) 
     , CONSTRAINT manager_invoice_emp_fk FOREIGN KEY (manager_emp_id) 
      REFERENCES manager_emp(emp_id) 
     , sales_invoice_amount    NUMBER (10) 
      CONSTRAINT sales_amount_check CHECK (sales_invoice_amount > 0));