whats wrong with this sql below. i cant make it run. CREATE TABLE SALE_02( SaleI
ID: 3814408 • Letter: W
Question
whats wrong with this sql below. i cant make it run.
CREATE TABLE SALE_02(
SaleID INT NOT NULL IDENTITY(20150001, 1),
DateOfSale DATE NOT NULL,
EmailAddress VARCHAR(100) NOT NULL,
SaleAmount NUMERIC(7,2) NOT NULL,
CONSTRAINT SALE_02_PK PRIMARY KEY(SaleID),
CONSTRAINT S_02_C004_FK FOREIGN KEY(CustomerID)
REFERENCES CUSTOMER_04(CustomerID)
ON UPDATE NO ACTION
);
this is what I have come up with to answer question 7.18 in chapter 7 of database processing(14th edition)
Explanation / Answer
there is nothing wrong with the code you have provided,the thing is the kind of database you are using for,IDENTITY works with MSSQL but not MySQL,instead you should use auto-increment and alter table for increament start point
CREATE TABLE SALE_02(
SaleID INT AUTO_INCREMENT NOT NULL,
DateOfSale DATE NOT NULL,
EmailAddress VARCHAR(100) NOT NULL,
SaleAmount NUMERIC(7,2) NOT NULL,
CONSTRAINT SALE_02_PK PRIMARY KEY(SaleID),
CONSTRAINT S_02_C004_FK FOREIGN KEY(CustomerID)
REFERENCES CUSTOMER_04(CustomerID)
ON UPDATE NO ACTION
);
ALL THE BEST :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.