假设我已经创建了一个表中的MySQL如下的MySQL插入数据问题
CREATE TABLE IF NOT EXISTS `sales` (
`id` smallint(5) unsigned NOT NULL auto_increment,
`client_id` smallint(5) unsigned NOT NULL,
`order_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`sub_total` decimal(8,2) NOT NULL,
`shipping_cost` decimal(8,2) NOT NULL,
`total_cost` decimal(8,2) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
--
-- Dumping data for table `sales`
--
如果我增加了一个新的领域must_fill当前表。
`must_fill` tinyint(1) unsigned NOT NULL,
默认情况下,用户可以插入少于fiels项目的数量,就像下面的脚本一样。
INSERT INTO `sales` (`id`, `client_id`, `order_time`, `sub_total`, `shipping_cost`, `total_cost`) VALUES
(8, 12312, '2007-12-19 01:30:45', 10.75, 3.00, 13.75);
这很好。
但是,当用户计划插入新数据时,如何将字段(must_fill)配置为必须包含数据字段。
顺便说一句,代码将被集成在PHP脚本中。
[更新] 或者,我只能写特殊的PHP脚本来判断must_fill为空或不是当用户试图运行插入脚本进入绑定一些数据值?
+1是的,严格的模式是实现这一点的唯一途径。 – 2010-05-05 03:22:49