Vi. MySQL field type selection

Source: Internet
Author: User

1the. Char Type field automatically removes the spaces that follow the string, and varchar does not2. Char faster than varchar .....3the. MyISAM suggests char types, memory char, like varchar, are treated as char types; INNODB suggested varchar type4. OptimizeTableCleanup Fragment text fragment generation instance:Create TableEMP (ID tinying (1), Contenttext) engine=MyISAM; new test tableInsert  intoEmpValues(1, Repeat ('www',10000) , insert 10000 continuous www with ID 1Insert  intoEmpValues(2, Repeat ('www',10000) , insert 10000 continuous www with ID 2Insert  intoEmpValues(3, Repeat ('www',10000) , insert 10000 continuous www with ID 3 The data file size for this table is: 250K (assuming)Delete  fromEmpwhereId= 3the data size of the table is still 250K, which creates a waste of space so this time it will be a fragment cleanup: OptimizeTableemp; Save 3./1 of the space is a la la la! 5The so-called composite index, in fact, will be stored in the text (data) to hash, and then use another field to store these hash values, find the time to find the hash value can find the corresponding disadvantage is only the exact match, for big data, no practical significance!! 6For programs with high precision, such as currency, you must use fixed-point numbers to describe the field7The date-time type is summarized according to the minimum selection: Any field type is stored in the smallest field mode~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.