PHPmyAdmin выдает ошибки, не может успешно импортировать sql; - PullRequest
0 голосов
/ 12 марта 2012

Итак, я пытаюсь создать коммерческую систему для назначения. Я использовал QSEE для создания ERD , вот его скриншот . Я пытался скопировать и вставить каждый отдельный оператор в функцию SQL, но он выдает сообщения об ошибках о несуществующих полях, импорт всего документа не работает:

CREATE TABLE _customer(
CustomerID  INTEGER NOT NULL,
FirstName   VARCHAR(20) NOT NULL,
LastName    VARCHAR(20) NOT NULL,
Building    VARCHAR(20) NOT NULL,
Address1    VARCHAR(30) NOT NULL,
Address2    VARCHAR(30),
City    VARCHAR(20) NOT NULL,
County  VARCHAR(20),
Postcode    VARCHAR(8) NOT NULL,
Phone   INTEGER,
Email   VARCHAR(30) NOT NULL,
Password    VARCHAR(20) NOT NULL,
BillingBuilding VARCHAR(20) NOT NULL,
BillingAddress1 VARCHAR(20) NOT NULL,
BillingAddress2 VARCHAR(20),
BillingCity VARCHAR(20) NOT NULL,
BillingCounty   VARCHAR(20),
BillingPostcode VARCHAR(8) NOT NULL,
ShippingBuilding    VARCHAR(20),
ShippingAddress1    VARCHAR(20),
ShippingAddress2    VARCHAR(20),
ShippingCity    VARCHAR(20),
ShippingCounty  VARCHAR(20),
ShippingPostcode    VARCHAR(8),
-- Specify the PRIMARY KEY constraint for table "_customer".
-- This indicates which attribute(s) uniquely identify each row of data.
CONSTRAINT  pk__customer PRIMARY KEY (CustomerID)
);

CREATE TABLE _product(
    ProductID   INTEGER NOT NULL,
    SKU INTEGER NOT NULL,
    Name    VARCHAR(20),
    Description VARCHAR(100),
    StockQuantity   INTEGER NOT NULL,
    UnitPrice   INTEGER NOT NULL,
    Size    VARCHAR(1) NOT NULL,
    Colour  VARCHAR(8) NOT NULL,
    Picture VARCHAR(15),
    LastUpdate  TIMESTAMP(8),
    fk1_SupplierID  INTEGER NOT NULL,
    -- Specify the PRIMARY KEY constraint for table "_product".
    -- This indicates which attribute(s) uniquely identify each row of data.
    CONSTRAINT  pk__product PRIMARY KEY (ProductID)
);

CREATE TABLE _customerorder(
    OrderID INTEGER NOT NULL,
    OrderDate   TIMESTAMP(8) NOT NULL,
    Amount  DECIMAL(8,2),
    fk1_PaymentID   INTEGER NOT NULL,
    fk2_CustomerID  INTEGER NOT NULL,
    -- Specify the PRIMARY KEY constraint for table "_customerorder".
    -- This indicates which attribute(s) uniquely identify each row of data.
    CONSTRAINT  pk__customerorder PRIMARY KEY (OrderID,fk1_CustomerID)
);

CREATE TABLE _payment(
    PaymentID   INTEGER NOT NULL,
    PaymentType VARCHAR(20) NOT NULL,
    -- Specify the PRIMARY KEY constraint for table "_payment".
    -- This indicates which attribute(s) uniquely identify each row of data.
    CONSTRAINT  pk__payment PRIMARY KEY (PaymentID)
);

CREATE TABLE _orderedproduct(
    OrderDetailID   INTEGER NOT NULL,
    Quantity    INTEGER,
    Total   INTEGER,
    Size    INTEGER,
    Colour  INTEGER,
    fk1_OrderID INTEGER NOT NULL,
    fk1_fk1_CustomerID  INTEGER NOT NULL,
    fk2_ProductID   INTEGER NOT NULL,
    -- Specify the PRIMARY KEY constraint for table "_orderedproduct".
    -- This indicates which attribute(s) uniquely identify each row of data.
    CONSTRAINT  pk__orderedproduct PRIMARY KEY (OrderDetailID)
);

CREATE TABLE _supplier(
    SupplierID  INTEGER NOT NULL,
    CompanyName VARCHAR(20) NOT NULL,
    SalesFirstName  VARCHAR(20) NOT NULL,
    SalesLastName   VARCHAR(20) NOT NULL,
    SalesTitle  VARCHAR(20),
    Address1    VARCHAR(20) NOT NULL,
    Address2    VARCHAR(20),
    City    VARCHAR(20),
    County  VARCHAR(20),
    Phone   INTEGER,
    Email   VARCHAR(30),
    -- Specify the PRIMARY KEY constraint for table "_supplier".
    -- This indicates which attribute(s) uniquely identify each row of data.
    CONSTRAINT  pk__supplier PRIMARY KEY (SupplierID)
);


ALTER TABLE _customerorder ADD CONSTRAINT fk1__customerorder_to__payment FOREIGN KEY(fk1_PaymentID) REFERENCES _payment(PaymentID) ON DELETE RESTRICT ON UPDATE RESTRICT;

ALTER TABLE _orderedproduct ADD CONSTRAINT fk1__orderedproduct_to__customerorder FOREIGN KEY(fk1_OrderID,fk1_fk1_CustomerID) REFERENCES _customerorder(OrderID,fk1_CustomerID) ON DELETE RESTRICT ON UPDATE RESTRICT;

ALTER TABLE _orderedproduct ADD CONSTRAINT fk2__orderedproduct_to__product FOREIGN KEY(fk2_ProductID) REFERENCES _product(ProductID) ON DELETE RESTRICT ON UPDATE RESTRICT;

ALTER TABLE _product ADD CONSTRAINT fk1__product_to__supplier FOREIGN KEY(fk1_SupplierID) REFERENCES _supplier(SupplierID) ON DELETE RESTRICT ON UPDATE RESTRICT;

ALTER TABLE _customerorder ADD CONSTRAINT fk2__customerorder_to__customer FOREIGN KEY(fk2_CustomerID) REFERENCES _customer(CustomerID) ON DELETE RESTRICT ON UPDATE RESTRICT

;

1 Ответ

1 голос
/ 12 марта 2012

Измените все типы TIMESTAMP (N) на TIMESTAMP. Параметр ширины (N) был удален давным-давно.

...