在服务器中执行 SQL 脚本
错误:错误 1067:“Users_Created”的默认值无效
CREATE TABLE IF NOT EXISTS `kwestionariusz_db`.`Companies` (
`CompanyId` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`Created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`Name` TEXT NOT NULL ,
`Users_UserId` INT UNSIGNED NOT NULL ,
`Users_Created` TIMESTAMP NULL DEFAULT NULL ,
PRIMARY KEY (`CompanyId`, `Created`, `Users_UserId`, `Users_Created`) ,
INDEX `fk_Companies_Users1` (`Users_UserId` ASC, `Users_Created` ASC) ,
CONSTRAINT `fk_Companies_Users1`
FOREIGN KEY (`Users_UserId` , `Users_Created` )
REFERENCES `kwestionariusz_db`.`Users` (`UserId` , `Created` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
所以,基本上,我做错了什么?我不希望在创建公司时更新 Users_Created,这会破坏关系。另外 - Companies.Created 是否会在更改时更新,例如 Companies.EMail?显然,我也不希望这样,但是将外键设为可空值无论如何都是错误的,对吧?所以我该怎么做?