Mysql storage engine and data type (2), mysql Data Type

Source: Internet
Author: User

Mysql storage engine and data type (2), mysql Data Type

Storage engine:
1. view supported storage engines:
Show engines \ G;
Show variables like 'have % ';
2. view the default storage engine:
Show variables like 'Storage _ engine % ';
3. Modify the default storage engine:
① You can use the Wizard to install the version:
"Start"-> "program"-> "MySQL"-> "MySQL Server 5.5"-> "MySQL Server Instance Configuration Wizard" to go to the welcome page of the graphical Instance Configuration Wizard. In the graphical instance Configuration Wizard, click "next" to go to "MySQL select purpose type". On this page, if you select "Multifunctional Database, the default storage engine is InnoDB. If you select the Non-Transaction Database Only button, the storage engine is MyISAM by default.
② The installation version or the installation-free version is another way to modify the default engine:
Open the my. ini configuration file and add the default-storage-engine = INNODB configuration to the [mysqld] group.

Data Type:
The database management system provides integer, floating point, point, and bit types, date and time types, and string types.

1. Integer type:
Tinyint (1 byte) smallint (2 byte) mediumint (3 byte) int and integer (4 byte) bigint (8 byte)
If the range of each integer cannot be distinguished, you can view related information through the mysql system.
• Mysql> help contents;
• Mysql> help Data Types;
• Mysql> help int;

2. floating point type, fixed point type, and bit type:
• Floating point number type: float (4-byte) double (8 byte) If You Need To Be precise to more than 10 decimal places, you need to select double
• Fixed Point Type: dec (M, D) (M + 2 bytes) decimal (M, D) (M + 2 bytes)
When the decimal precision is very high, it usually indicates that decimal is preferred for the amount.
• Bit type: bit (1-8 bytes)
Note: decimal () has a total length of 18 digits, including one decimal point and four decimal places. That is to say, 18-1-4 = 13 digits only 13 digits M: total length D: decimal Digits

3. Date and Time types:
• Data (4 bytes)
• Datatime (8 bytes)
• Timestamp (4 bytes)
• Time (3 bytes)
• Year (1 byte)
Each date and time data type has a value range. If the inserted value exceeds the value range of this type, the default value is inserted.
• To indicate year, month, and day, date is generally used
• To indicate year, month, day, hour, minute, and second, datetime is generally used
• If you need to insert or update the date frequently as the current system time, the timestamp type is generally used.
• To indicate the time, minute, and second, time is generally used.
• To indicate the year, year is generally used, because this type occupies less space than date.

4. string type:
Char string:
• Char (M) M byte M is an integer between 0 and 25 5
• The length of an integer between 0 and MB in varchar (M) M is variable.
Note: UTF-8: a Chinese character = 3 bytes, English is a byte; GBK: a Chinese character = 2 bytes, English is a byte

Text string type:
• Tinytext (0-255 bytes)
• Text (0-65535 bytes)
• Mediumtext (0-167772150 bytes)
• Longtext (0-4294967295 bytes)

Binary series string type:
• Binary (M) M is a byte value with a length of 0-M
• Varbinary (M) M is a byte allowed length of 0-M

Note: These two types are different from the preceding char and varchar types. The difference is that char stores character data, and binary stores binary data (images, music, and videos)
Blob series string type:
• Tinyblob 0-255 bytes
• Blob 0-2 power 16
• Mediumblob 0-2 to the power of 24
• Longblob 0-2 power 32
Note: This group is of the text type. The difference is that this group can store binary data (images, music, and videos), while the text group can only store character data.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.