2016-11-08 40 views
0
`CREATE TABLE IF NOT EXISTS `Odin`.`Usuario` (
    `CodUsuario` INT NOT NULL AUTO_INCREMENT, 
    `CodTipoUsuario` INT NOT NULL, 
    `CodConsultorTecnico` INT NULL, 
    `CodProdutor` INT NULL, 
    `Login` VARCHAR(255) CHARACTER SET 'utf8mb4' NOT NULL, 
    `Senha` VARCHAR(32) CHARACTER SET 'utf8mb4' NOT NULL, 
    `Ativo` TINYINT(1) NOT NULL, 
    `MaiorDataRegistrada` DATETIME NOT NULL, 
    `DataLimite` DATETIME NOT NULL DEFAULT '01/01/2014', 
    `MaxFazendas` INT NOT NULL DEFAULT 0, 
    `MaxFemeas` INT NOT NULL DEFAULT 0, 
    `CodUserWeb` INT NOT NULL DEFAULT 0, 
    `CodEstudante` INT NULL, 
    `UltimoBackup` DATETIME NULL, 
    PRIMARY KEY (`CodUsuario`), 
    UNIQUE INDEX `UQ__Usuario__00000000000006D8` (`Login` ASC), 
    CONSTRAINT `FK_Usu_ref_Est` 
    FOREIGN KEY (`CodEstudante`) 
    REFERENCES `Odin`.`Estudante` (`CodEstudante`) 
    ON DELETE NO ACTION 
    ON UPDATE NO ACTION, 
    CONSTRAINT `Fk_Usuario_Ref_Consultor` 
    FOREIGN KEY (`CodConsultorTecnico`) 
    REFERENCES `Odin`.`ConsultorTecnico` (`CodConsultorTecnico`) 
    ON DELETE NO ACTION 
    ON UPDATE NO ACTION, 
    CONSTRAINT `Fk_Usuario_Ref_Produtor` 
    FOREIGN KEY (`CodProdutor`) 
    REFERENCES `Odin`.`Produtor` (`CodProdutor`) 
    ON DELETE NO ACTION 
    ON UPDATE NO ACTION, 
    CONSTRAINT `Fk_Usuario_Ref_TipoUsuario` 
    FOREIGN KEY (`CodTipoUsuario`) 
    REFERENCES `Odin`.`ConfTipoUsuario` (`CodTipoUsuario`) 
    ON DELETE NO ACTION 
    ON UPDATE NO ACTION) ` 

我試圖解決方案,如: ENGINE = InnoDB的默認字符集= UTF8 COLLATE = utf8_unicode_ci; 或 ENGINE = InnoDB DEFAULT CHARSET = utf16 COLLATE = utf8_unicode_ci;我的SQL腳本埃羅1071 - 不起作用添加特定或更換髮動機

或添加唯一

,仍然繼續錯誤:

1071 - 指定的鍵過長;最大密鑰長度是767字節

有人可以幫助我嗎?謝謝

+0

[#1071 - 指定的密鑰太長;最大密鑰長度是767字節](http://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes) – DanFromGermany

+0

我看到了這個解決方案,但無法使它工作,無論如何感謝嘗試 –

回答

0

您正在使用utf8mb4這是每個字符1-4個字節。

您選擇VARCHAR(255) - 255個字符* 4個字節= 1020

嘗試用更少的字符。像VARCHAR(191)。您也可以查看innodb_large_prefix