English 中文(简体)
第1栏“战略”的范围值
原标题:Out of Range values for "commrate" at column 1
  • 时间:2011-11-23 23:20:59
  •  标签:
  • mysql
  • 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 );

But I am encountering Script line: 12 Out of range value for column Commrate at row 1 Any mistake I am making?

问题回答

定值(3,2)是指允许的最高值为9.99

检查官方手册





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签