我可以用“IDENTITY”代替什么才能使这个工作?

时间:2018-05-23 15:15:54

标签: mysql

Create Table Customer(
CustomerID Int NOT NULL IDENTITY (1,1) , 
LastName Char(25) NOT NULL,
FirstName Char(25) NOT NULL,
EmailAddress VarChar(100) NOT NULL,
EncryptedPassword VarChar(50) NULL,
Phone Char(12) NOT NULL,
StreetAddress Char(35) NULL
City Char(35) NULL DEFAULT 'Dallas', 
[State] Char(2) NULL DEFAULT 'TX', 
ZIP Char(10) NULL DEFAULT '75201',
CONSTRAINT CUSTOMER_PK PRIMARY KEY(CUSTOMERID),
CONSTRAINT CUSTOMER_EMAIL UNIQUE(EMAILADDRESS)
) ;

CREATE TABLE SEMINAR(
SeminarID INT NOT NULL IDENTITY (1, 1), 
SeminarDate Date NOT NULL,
SeminarTime Time NOT NULL,
Location VarChar(100) NOT NULL,
SeminarTitle VarChar(100)
CONSTRAINT SEMINAR_PK PRIMARY KEY(SeminarID)
) ;

Create Table SEMINAR_CUSTOMER(
SeminarID Int NOT NULL,
CustomerID Int NOT NULL,
CONSTRAINT S_C_PK PRIMARY KEY(SeminarID, CustomerID), 
CONSTRAINT S_C_SEMINAR_FK FOREIGN KEY(SeminarID)
              REFERENCES SEMINAR(SeminarID)
                 ON UPDATE NO ACTION
                 ON DELETE NO ACTION
CONSTRAINT S_C_CUSTOMER_FK FOREIGN KEY (CustomerID)
              REFERENCES CUSTOMER(CustomerID)
                 ON UPDATE NO ACTION
                 ON DELETE NO ACTION
) ;   
CREATE TABLE CONTACT(
CustomerID Int NOT NULL,
ContactNumber Int NOT NULL,
ContactDate Date NOT NULL,
ContactType VarChar(30) NOT NULL,
SeminarID Int NULL,
CONSTRAINT CONTACT_PK PRIMARY KEY(CustomerID, ContactNumber),
CONSTRAINT CONTACT_ContactType
              CHECK (ContactType IN ('Seminar',
                     'WebAccountCreation', 'WebPurchase',
                     'EmailAccountMessage', 'EmailSeminarMessage',
                     'EmailPurcahseMessage',
                     'EmailMessageExchange', 'FormLetterSeminar',
                     'PhoneConversation')),
CONSTRAINT CONTACT_SEMINAR_FK FOREIGN KEY(SeminarID)
              REFERENCES SEMINAR(SeminarID)
                 ON UPDATE NO ACTION
                 ON DELETE NO ACTION,
CONSTRAINT CONTACT_SEMINAR_FK FOREIGN KEY(SeminarID)
              REFERENCES SEMINAR(CustomerID)
                 ON UPDATE NO ACTION
                 ON DELETE NO ACTION
);

CREATE TABLE PRODUCT(
ProductNumber Char(35) NOT NULL,
ProductType Char(24) NOT NULL,
ProductDescription VarChar(100) NOT NULL,
UnitPrice Numeric(9,2) NOT NULL
QuantityOnHand Int NULL
CONSTRAINT PRODUCT_PK PRIMARY KEY(ProductNumber),
CONSTRAINT PRODUCT_ProductType
              CHECK (ProductType) IN ('Video', 
                    'Video Companion', 'Book'))
);
CREATE TABLE INVOICE(
InvoiceNumber Int NOT NULL IDENTITY  (35000, 1),
  InvoiceDate Date NOT NULL,
  CustomerID Int NOT NULL,
  PaymentType Char(25) NOT NULL DEFAULT 'Cash',
  SubTotal Numeric(9,2) NULL,
  Shipping Numeric(9,2) NULL,
  Tax Numeric(9,2) NULL,
  Total Numeric(9,2) NULL,
  CONSTRAINT INVOICE_PK PRIMARY KEY (InvoiceNumber),
  CONSTRAINT INVOICE_PaymentType
                CHECK (PaymentType IN ('VISA',
                       'MasterCard', 'American Express',
                       'PayPal', 'Check', 'Cash')),
  CONSTRAINT INVOICE_CUSTOMER_FK FOREIGN KEY(CustomerID)
                REFERENCES CUSTOMER(CustomerID)
                   ON UPDATE NO ACTION
                   ON DELETE NO ACTION
);

CREATE TABLE LINE_ITEM(
      InvoiceNumber Int NOT NULL,
      LineNumber Int NOT NULL,
      ProductNumber Char(35) NOT NULL,
      Quantity Int NOT NULL
      UnitPrice Numeric(9,2) NULL
      Total Numeric(9,2) NULL
      CONSTRAINT LINE_ITEM_PK PRIMARY KEY (InvoiceNumber, LineNumber),
      CONSTRAINT L_I_INVOICE_FK FOREIGN KEY (InvoiceNumber)
                    REFERENCES INVOICE(InvoiceNumber)
                       ON UPDATE NO ACTION
                       ON DELETE NO ACTION
      CONSTRAINT L_I_PRODUCT_FK FOREIGN KEY (ProductNumber)
                    REFERENCES Product (ProductNumber)
                       ON UPDATE NO ACTION
                       ON DELETE NO ACTION
);

有我的整个代码。直接从书中复制一堂课。我的教授不会帮助我,所以我希望在这里能够提供帮助。过去3天我没有做过任何事情。这是我为所有'IDENTITY'保留的错误消息:

  

IDENTITY在此位置无效输入,期望:')'

请帮忙,我今天需要这个。

0 个答案:

没有答案