I'm doing excercises from the db kroenke book. Anyone can see why this insert:
INSERT INTO PRODUCT_SALES VALUES(41197, 3, 'VK001', 1, 14.95, 14.95);
doesn't work on the following table:
CREATE TABLE PRODUCT_SALES(
TimeID Int NOT NULL,
CustomerID Int NOT NULL,
ProductNumber Char(35) NOT NULL,
Quantity Int NOT NULL,
UnitPrice Numeric(9,2) NOT NULL,
Total Numeric(9,2 ) NULL,
CONSTRAINT SALES_PK
PRIMARY KEY (TimeID, CustomerID, ProductNumber),
CONSTRAINT PS_TIMELINE_FK FOREIGN KEY(TimeID)
REFERENCES TIMELINE(TimeID)
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT PS_CUSTOMER_FK FOREIGN KEY(CustomerID)
REFERENCES CUSTOMER(CustomerID)
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT PS_PRODUCT_FK FOREIGN KEY(ProductNumber)
REFERENCES PRODUCT(ProductNumber)
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
The format looks fine but getting this error:
Column name or number of supplied values does not match table definition.
Thanks!
3条答案
按热度按时间hi3rlvi21#
Just used the column names in the Insert statement and it has worked.
-- Added column names in the insert statement and it worked.
gkn4icbw2#
I tried the same query in my mysql the insert query seems to work fine! Is the table altered?
voj3qocg3#
Did you created this table before with different columns or column order?
Can you try