gpt4 book ai didi

mysql - 第 1 列 "commrate"的值超出范围

转载 作者:行者123 更新时间:2023-11-29 09:02:20 24 4
gpt4 key购买 nike

我使用以下 SQL 脚本创建了此表,

CREATE TABLE part
(Partno CHAR(4) PRIMARY KEY,
Partdesc VARCHAR(20),
Onhand INTEGER,
Partclass CHAR(2) check (Partclass IN ('AP','HW','KI','SP')),
Unitprice DECIMAL(6,2)
);


CREATE TABLE salesrep
(Srepno CHAR(3),
Srepname VARCHAR(25),
Srepstreet VARCHAR(30),
Srepcity VARCHAR(15) NOT NULL,
Srepprov VARCHAR(3) NOT NULL,
Sreppcode VARCHAR(6) NOT NULL,
Totcomm DECIMAL(8,2),
Commrate DECIMAL(3,2),
CONSTRAINT pkslsrep PRIMARY KEY (Srepno)
);


CREATE TABLE customer
(Custno CHAR(3),
Custname VARCHAR(25) NOT NULL,
Custstreet VARCHAR(30) NOT NULL,
Custcity VARCHAR(15) NOT NULL,
Custprov VARCHAR(3) NOT NULL,
Custpcode VARCHAR(6) NOT NULL,
Disc DECIMAL(3,1),
Balance DECIMAL(7,2),
Credlimit DECIMAL(5),
Srepno CHAR(3),
CONSTRAINT pkcustno PRIMARY KEY (Custno),
CONSTRAINT fksrepno FOREIGN KEY (Srepno) REFERENCES salesrep(Srepno)
);


CREATE TABLE orders
(Orderno CHAR(5) UNIQUE NOT NULL,
Orderdate DATE,
Custno CHAR(3) NOT NULL,
CONSTRAINT fkordercust FOREIGN KEY (Custno) REFERENCES customer (Custno)
);


CREATE TABLE orderprod
(Orderno CHAR(5),
Partno CHAR(4),
Orderqty INTEGER CHECK (Orderqty>0),
Orderprice DECIMAL(7,2),
CONSTRAINT pkorderprod PRIMARY KEY (Orderno, Partno),
CONSTRAINT fkordprdord FOREIGN KEY (Orderno) REFERENCES orders(Orderno),
CONSTRAINT fkordprdpar FOREIGN KEY (Partno) REFERENCES part(Partno)
);


CREATE TABLE invoice
( Invno CHAR(6),
Invdate DATE,
Orderno CHAR(5),
CONSTRAINT fkinvoice FOREIGN KEY (Orderno) REFERENCES orders(Orderno),
CONSTRAINT pkinvoice PRIMARY KEY (Invno)
);


CREATE TABLE invprod
( Invno CHAR(6),
Partno CHAR(4),
Shipqty INTEGER CHECK (Shipqty>0),
CONSTRAINT fkinvoic FOREIGN KEY (Invno) REFERENCES invoice(Invno),
CONSTRAINT fkpart FOREIGN KEY (Partno) REFERENCES part(Partno)
);

然后我尝试使用以下脚本添加一些记录,

INSERT INTO part(Partno, Partdesc, Onhand, Partclass, Unitprice) VALUES('1542','Exhaust Fans', '32', 'KI', '259.99');
INSERT INTO part(Partno, Partdesc, Onhand, Partclass, Unitprice) VALUES('1489','Washing Machine IFB', '10', 'AP', '1499.99');
INSERT INTO part(Partno, Partdesc, Onhand, Partclass, Unitprice) VALUES('1378','Cleaning Kit', '40', 'HW', '19.99');
INSERT INTO part(Partno, Partdesc, Onhand, Partclass, Unitprice) VALUES('1256','Soccer Ball', '15', 'SP', '20.99');

INSERT INTO salesrep(Srepno, Srepname, Srepstreet, Srepcity, Srepprov, Sreppcode, Totcomm, Commrate) VALUES('125','Dwayne Johnson', 'Aidelaide Street', 'Toronto', 'ON', 'L6T7U7', '2566.58', '12');
INSERT INTO salesrep(Srepno, Srepname, Srepstreet, Srepcity, Srepprov, Sreppcode, Totcomm, Commrate) VALUES('147','Sean Mathews', 'Hurontario Street', 'Brampton', 'ON', 'L6Y5H7', '3400.89', '15');

INSERT INTO customer(Custno, Custname, Custstreet, Custcity, Custprov, Custpcode, Disc, Balance, Credlimit, Srepno) VALUES('589','Ankur Kaushal', 'Listcreek Road', 'Brampton', 'ON', 'L6P2N7', '20.0','0.00', '500', '125');
INSERT INTO customer(Custno, Custname, Custstreet, Custcity, Custprov, Custpcode, Disc, Balance, Credlimit, Srepno) VALUES('458','Iqbal Jassal', 'Bayridge Dr', 'Brampton', 'ON', 'L7U5D5', '10.0','100.00', '500', '147');

INSERT INTO orders(Orderno, Orderdate, Custno) VALUES('14587','2011-11-09', '125' );
INSERT INTO orders(Orderno, Orderdate, Custno) VALUES('11547','2011-11-07', '125' );

INSERT INTO orderprod(Orderno, Partno, Orderqty, Orderprice) VALUES('14587','1256', '2', '41.98' );
INSERT INTO orderprod(Orderno, Partno, Orderqty, Orderprice) VALUES('11547','1489', '1', '1499.99' );

INSERT INTO invoice(Invno, Invdate, Orderno) VALUES('578977','2011-11-09', '14587');

INSERT INTO invprod(Invno, Partno, Shipqty) VALUES('578977','1256', '2');

但是我遇到了“脚本行:12 超出第 1 行“Commrate”列的值范围'我犯了什么错误吗?

最佳答案

十进制(3,2)表示允许的最大值是9.99

看看官方手册

http://dev.mysql.com/doc/refman/5.0/en/precision-math-decimal-changes.html

关于mysql - 第 1 列 "commrate"的值超出范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8250431/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com