Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE `phppos_modules_actions` (
- `action_id` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
- `module_id` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
- `action_name_key` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
- `sort` INT NOT NULL ,
- PRIMARY KEY ( `action_id` , `module_id` )
- ) ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_unicode_ci;
- Options in my.cnf
- sql-mode=""
- default-storage-engine=MYISAM
- skip-innodb uncommented (without#)
- Return on execution of your create statement:
- Error Code: 1071. Specified key was too long; max key length is 1000 bytes
- Explanation: INNODB is not active, the engine is automatically switched to MYISAM
- that returns this error as they key is longer than MYISAM 1000 bytes limit.
- The key length is:
- 2 fields x 255 char x 3 bytes utf8 encoding + 2 x 1 length byte = 1532 bytes
- Options in my.cnf
- sql-mode="NO_ENGINE_SUBSTITUTION"
- default-storage-engine=MYISAM
- skip-innodb uncommented (without#)
- Return on execution of your create statement:
- Error Code: 1286. Unknown table engine 'INNODB'
- Explanation: INNODB is not active but the engine substitution is not permitted
- by sql mode therefore the DB returns an error about the attempt of using a disabled engine.
- Options in my.cnf
- sql-mode="NO_ENGINE_SUBSTITUTION"
- default-storage-engine=MYISAM
- skip-innodb commented (with#)
- Return on execution of your create statement:
- Table creation OK!
- Explanation: INNODB is active (skip-innodb commented) and it is used also if
- the default engine is MYISAM.
- Error Code: 1071. Specified key was too long; max key length is 1000 bytes
- Error Code: 1071. Specified key was too long; max key length is 767 bytes
- 256 x 3 + 2 = 770 bytes
- 255 x 3 + 1 = 766 bytes
- Error Code: 1071. Specified key was too long; max key length is 767 bytes
- Error Code: 1071. Specified key was too long; max key length is 3072 bytes
- CREATE TABLE `phppos_modules_actions` (
- `action_id` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
- `module_id` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
- `action_name_key` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
- `action_name_key1` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
- `action_name_key2` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
- `sort` INT NOT NULL ,
- PRIMARY KEY ( `action_id` , `module_id`, `action_name_key`, `action_name_key1`, `action_name_key2` )
- ) ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_unicode_ci;
- Error Code: 1071. Specified key was too long; max key length is 3072 bytes
- KEY `key_name` (`action_id`(50),`module_id`(50))
- CREATE TABLE `phppos_modules_actions` (
- `action_id` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
- `module_id` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
- `action_name_key` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
- `sort` INT NOT NULL ,
- PRIMARY KEY ( `action_id`(50) , `module_id`(50) )
- ) ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_unicode_ci;
- SELECT
- ROUND(SUM(LENGTH(`action_id`)<10)*100/COUNT(*),2) AS pct_length_10,
- ROUND(SUM(LENGTH(`action_id`)<20)*100/COUNT(*),2) AS pct_length_20,
- ROUND(SUM(LENGTH(`action_id`)<50)*100/COUNT(*),2) AS pct_length_50,
- ROUND(SUM(LENGTH(`action_id`)<100)*100/COUNT(*),2) AS pct_length_100
- FROM `phppos_modules_actions`;
- +---------------+---------------+---------------+----------------+
- | pct_length_10 | pct_length_20 | pct_length_50 | pct_length_100 |
- +---------------+---------------+---------------+----------------+
- | 42.86 | 80.20 | 100 | 100 |
- +---------------+---------------+---------------+----------------+
Add Comment
Please, Sign In to add comment