MySQL查询:
CREATE TABLE ORD( ORDID NUMERIC( 4 ) NOT NULL , ORDERDATE DATE, COMMPLANCHAR( 1 ) , CUSTID NUMERIC( 6 ) NOT NULL , SHIPDATE DATE, TOTAL NUMERIC( 8, 2 ) CONSTRAINT TOTAL_ZERO CHECK (
TOTAL >=0
), CONSTRAINT ORD_FOREIGN_KEY FOREIGN KEY ( CUSTID ) REFERENCES CUSTOMER( CUSTID ) , CONSTRAINT ORD_PRIMARY_KEY PRIMARY KEY ( ORDID ) ) ;
MySQL说:文档
#1064-您的SQL语法有误;检查手册
对应于您的MySQL服务器版本以使用正确的语法
“ CONSTRAINT TOTAL_ZERO CHECK(TOTAL> = 0)附近,CONSTRAINT
第8行的ORD_FOREIGN_KEY FOREIGN KE'
最佳答案
您错过了逗号和空格
CREATE TABLE ORD
(
ORDID NUMERIC( 4 ) NOT NULL,
ORDERDATE DATE,
COMMPLAN CHAR( 1 ),
CUSTID NUMERIC( 6 ) NOT NULL,
SHIPDATE DATE,
TOTAL NUMERIC( 8, 2 ),
CONSTRAINT TOTAL_ZERO CHECK (TOTAL >= 0),
CONSTRAINT ORD_FOREIGN_KEY FOREIGN KEY ( CUSTID ) REFERENCES CUSTOMER( CUSTID ),
CONSTRAINT ORD_PRIMARY_KEY PRIMARY KEY ( ORDID )
);
而且AFAIK MySQL会忽略
check
约束。关于mysql - Phpmyadmin中的mysql#1064错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19877001/