Appserv代码错误#1064-You have an error in your SQL syntax;check the manual that corresponds

SQL query:
CREATE TABLE amercement('AmerceNO'number, 'BorrowNO'number, 'StudentNO'VARCHAR, 'Detail'VARCHAR( 20 ) NOT NULL , 'Mulct'number( 5, 2 ) NOT NULL , 'Pay'number( 1 ) default 0, 'PayTime'varchar( 20 ) , PRIMARY KEY ( 'AmerceNO' ) , FOREIGN KEY ( 'BorrowNO' ) REFERENCES borrow_list( 'BorrowNO' ) ON DELETE CASCADE , FOREIGN KEY ( 'StudentNO' ) REFERENCES student( 'StudentNO' ) ON DELETE CASCADE
) ENGINE = MYISAM

MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''AmerceNO' number , 'BorrowNO' number, 'StudentNO' VARCHAR, 'Detail' VARCH' at line 3

你有三处错误
1、不能用单引号(‘)应该用(`),也可以不用引号。
2、VARCHAR类型必须指定大小。
3、mysql中用的是numeric而不是number。

修改后的sql
CREATE TABLE amercement(
`AmerceNO` numeric,
`BorrowNO` numeric,
`StudentNO` VARCHAR(20),
`Detail` VARCHAR(20) NOT NULL,
`Mulct` numeric(5, 2) NOT NULL,
`Pay` numeric(1) default 0,
`PayTime` VARCHAR(20),
PRIMARY KEY (`AmerceNO`) ,
FOREIGN KEY (`BorrowNO`) REFERENCES borrow_list(`BorrowNO`) ON DELETE CASCAD,
FOREIGN KEY (`StudentNO`) REFERENCES student(`StudentNO`) ON DELETE CASCADE
) ENGINE = MYISAM
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-12-21
话说你的mysql语句哪里学的?我怎么就看不懂呢?MySQL中有number这种类型么?我怎么只记得有int这种啊?追问

抄错代码了,改过来还是不对啊

 

第2个回答  2019-07-30
应该是你的MYSQ版本不支持select from 数字表名。
第3个回答  2019-04-27
加上数据库前缀试一下,不然系统不知道表属于哪个数据库,比如数据库名.表名
相似回答