我应用了约束,但未考虑。
即使您输入的评分为63(即使不允许)也会被接受。
CREATE TABLE IF NOT EXISTS `song` (
`id` int(6) NOT NULL, -- may be needed
`name` varchar(15) NOT NULL,
`type` varchar(15) NOT NULL,
`rate` varchar(2) NOT NULL,
CONSTRAINT chk_rate CHECK (rate IN ('1','2','3','4','5','6','7','8','9','10')),
`release date` int(10) NOT NULL,
PRIMARY KEY (`id`)
) ;
INSERT INTO `song` (`id`, `name`, `type`,`rate`,`release date`) VALUES
('1', 'bye bye', 'rock',63,2010),
('2', 'this is fun ', 'pop',6,2006),
('3', 'the drink', 'trance',8,2009),
('4', ' cars', 'rock',8,2008),
('5', 'this snow', 'ost',8,2012);