Skip to Content
MySQL 8 Cookbook
book

MySQL 8 Cookbook

by Karthik Appigatla
January 2018
Intermediate to advanced
446 pages
12h 57m
English
Packt Publishing
Content preview from MySQL 8 Cookbook

How to do it...

  1. If you want to store an employee number, for which the maximum possible value is 500,000, the optimum datatype is MEDIUMINT UNSIGNED (which occupies 3 bytes). If you are storing it as INT, which occupies 4 bytes, you are wasting a byte for each row.
  2. If you want to store the first name, for which the length is varying and the maximum possible value is 20, it is optimal to declare it as varchar(20). If you are storing it as char(20), and just a few names are 20 characters long while the remaining are less than 10 characters long, you are wasting space of 10 characters.
  3. While declaring varchar columns, you should consider the length. Though varchar is optimized on-disk, while loading into memory, it occupies the full length. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

MySQL Cookbook

MySQL Cookbook

Paul DuBois
Advanced MySQL 8

Advanced MySQL 8

Eric Vanier, Birju Shah, Tejaswi Malepati

Publisher Resources

ISBN: 9781788395809Other