I would like to create this table:
CREATE TABLE IF NOT EXISTS `my-database`.`user_product` (
`user_product_id` INT NOT NULL AUTO_INCREMENT,
`FK_user_id` INT NOT NULL,
`created_at` DATETIME NOT NULL,
`long_column_1` VARCHAR(10000) NOT NULL,
`long_column_2` VARCHAR(10000) NULL DEFAULT NULL,
`deleted_at` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`user_product_id`),
INDEX `user_id_idx` (`FK_user_id` ASC) VISIBLE,
CONSTRAINT `FK_user_id`
FOREIGN KEY (`FK_user_id`)
REFERENCES `my-database`.`user` (`user_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
client needs of two columns that can be very short or very long, "long_column_1" and "long_column_2", (ignore their name, it's just for the example). I read that TEXT type is slow compared to VARCHAR, probably 99% of times both columns will be shorter than 255, so I created them VARCHAR(10000) and not TEXT.
Why does it give "Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535" error?
The total size is not greater than 65535, because 10000+10000 = 20000.
This is the "user" table, just in case you need it:
CREATE TABLE IF NOT EXISTS `my-database`.`user` (
`user_id` INT NOT NULL AUTO_INCREMENT,
`username` VARCHAR(45) NOT NULL,
`password` VARCHAR(60) NOT NULL,
PRIMARY KEY (`user_id`),
UNIQUE INDEX `username_UNIQUE` (`username` ASC) VISIBLE)
ENGINE = InnoDB;
I'm using MySql 8