MySQL Insert Data Question
- by Nano HE
Hi, assume I already created a table in MySQL as below
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`
--
If I added a new field must_fill for the current table.
`must_fill` tinyint(1) unsigned NOT NULL,
User can insert less than the number of fiels items to the table defaultly, just as the script of below.
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);
It's fine.
But How can I configure the field (must_fill) to a MUST INCLUDE Data field when user plan to insert into new data.
BTW, The code will be integrated in PHP script.