下面的代码显示oracle中无效标识符的错误

时间:2014-08-22 11:02:13

标签: sql oracle identifier

create table productinfotwo
(
productId number(10),
CONSTRAINT primary_pk Primary Key(productId),
productname varchar2(100),
SUBCATEGORYID number(10),
CONSTRAINT subcategory_fk Foreign Key(SUBCATEGORYID ) REFERENCES ProductSubCategory(SUBCATEGORYID ), 
COMPANYID varchar2(20), 
CONSTRAINT company_fk Foreign Key(COMPANYID ) References CompanyInfo(COMPANYID ),
price float,
quantity number(10),
description varchar2(1000),
);

1 个答案:

答案 0 :(得分:1)

您需要按顺序使用

  1. 创建ProductSubCategory表
  2. 创建CompanyInfo表
  3. Oracle中没有名为float的数据类型。您可以使用NUMBER(4,2)代替
  4. 删除说明后的逗号
  5. 代码应为

    CREATE TABLE productinfotwo 
      ( 
         productid     NUMBER(10), 
              CONSTRAINT primary_pk PRIMARY KEY(productid), 
              productname   VARCHAR2(100), 
              subcategoryid NUMBER(10), 
              CONSTRAINT subcategory_fk FOREIGN KEY(subcategoryid ) REFERENCES 
              productsubcategory(subcategoryid ), 
              companyid     VARCHAR2(20), 
              CONSTRAINT company_fk FOREIGN KEY(companyid ) REFERENCES companyinfo( 
              companyid ), 
         price         NUMBER(4, 2), 
         quantity      NUMBER(10), 
         description   VARCHAR2(1000) 
      );