I have this script:
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_ALL_TABLES';
SET SQL_MODE = `STRICT_ALL_TABLES`;
CREATE TABLE IF NOT EXISTS `w_bank_account` (
`account_id` INT NOT NULL AUTO_INCREMENT,
`bank_id` INT(11) NOT NULL,
`account_number` VARCHAR(20) NOT NULL,
`account_type` ENUM('1','2') NOT NULL,
`balance` DECIMAL(19,4) NOT NULL DEFAULT 0,
`created` TIMESTAMP NOT NULL,
`modified` TIMESTAMP NULL,
PRIMARY KEY (`account_id`),
CONSTRAINT `fk_w_bank_account_n_bank1`
FOREIGN KEY (`bank_id`)
REFERENCES `n_bank` (`id`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `fk_w_bank_account_n_bank1_idx` ON `w_bank_account` (`bank_id` ASC);
I try this two queries:
INSERT INTO `w_bank_account` (`bank_id`, `account_number`, `account_type`, `balance`) VALUES
(1, '01234567890123456789', '1', 0.0000),
(1, '01234567890123456789', '6', 0.0000);
And it works but in the second insert it leaves account_type
empty (I think this goes to NULL) :-O why if I'm setting SQL_MODE
as STRICT_ALL_TABLES? Should not the ENUM
field gets the first value instead of leave field NULL
? I'm using MySQL 5.5.31 on Debian