7
When I run this code on Mariadb, it gives me this error when trying to create the toy table:
ERROR 1709 (HY000): Index column size Too large. The Maximum column size is 767 bytes.
I don’t know how to fix it, Mariadb has already been installed on my system Parrot Sec (A distro based on Debian). Can anyone help me?
CREATE TABLE IF NOT EXISTS categoria (
categoria_id INT(11) unsigned NOT NULL AUTO_INCREMENT,
categoria_nome VARCHAR(80) NOT NULL,
PRIMARY KEY (categoria_id),
UNIQUE INDEX categoria_nome_UNIQUE (categoria_nome ASC));
CREATE TABLE IF NOT EXISTS brinquedo (
brinquedo_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
brinquedo_descricao VARCHAR(200) NULL DEFAULT NULL,
brinquedo_imagem_url VARCHAR(200) NOT NULL,
brinquedo_preco DECIMAL(9,2) NOT NULL,
brinquedo_detalhes VARCHAR(200) NULL DEFAULT NULL,
brinquedo_categoria_id INT(11) NOT NULL,
brinquedo_marca VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (brinquedo_id),
UNIQUE INDEX brinquedo_imagem_url_UNIQUE (brinquedo_imagem_url ASC),
CONSTRAINT fk_brinquedo_categoria
FOREIGN KEY (brinquedo_categoria_id)
REFERENCES categoria (categoria_id)
ON DELETE CASCADE
ON UPDATE CASCADE);
Field 'long' as varchar are not good candidates for indices. To be an Index it should not exceed a certain value (see the documentation for the number of Blocks) to be useful. The problem seems to be
brinquedo_imagem_url
. If I am not mistaken in Mysql the limit is 120. Suggestion remove the Dice from that column or if possible decrease the number of characters.– rray
I did that, and now he has error in creating the Foreign: brinquedo_tag VARCHAR(45) NULL DEFAULT NULL, PRIMARY KEY (brinquedo_id), CONSTRAINT fk_brinquedo_category FOREIGN KEY (brinquedo_categoria_id) CATEGORY (categoria_id) ON DELETE CASCADE ON UPDATE CASCADE); ERROR 1005 (HY000): Can’t create table
brinquedos
.brinquedo
(Rrno: 150 "Foreign key Constraint is incorrectly Formed")– Patterson Silva