MySQL 欄位塞入空值的語法
MySQL 欄位塞入空值的語法
CREATE TABLE IF NOT EXISTS `int_char` (
`id` int(11) NOT NULL,
`name` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
———–
INSERT INTO `int_char`(`id`, `name`) VALUES (null,’d’); (X- #1048 – Column ‘id’ cannot be null)
INSERT INTO `int_char`(`id`, `name`) VALUES (NULL,’d’); (X- #1048 – Column ‘id’ cannot be null)
INSERT INTO `int_char`(`id`, `name`) VALUES (2,null); (X- #1048 – Column ‘id’ cannot be null)
INSERT INTO `int_char`(`id`, `name`) VALUES (2,NULL); (X- #1048 – Column ‘id’ cannot be null)
INSERT INTO `int_char`(`id`, `name`) VALUES (‘2’,null); (X- #1048 – Column ‘id’ cannot be null)
INSERT INTO `int_char`(`id`, `name`) VALUES (‘2’,NULL); (X- #1048 – Column ‘id’ cannot be null)
INSERT INTO `int_char`(`id` ,`name`) VALUES (”, ‘d’); (O-插入了 1 行。 (查詢花費 0.0295 秒))
INSERT INTO `int_char`(`id` ,`name`) VALUES (‘2’, ”); (O-插入了 1 行。 (查詢花費 0.0385 秒))
———–
結論:
空值就用”來取代即可