mysql資料型別
Summary: in this tutorial, you will learn about MySQL data types and how to use them effectively in the MySQL database design.
Database table contains multiple columns with specific data types such as numeric or string. MySQL provides more data types other than just numeric or string. Each data type in MySQL can be determined by the following characteristics:
Kind of values it can represent.
The space that takes up and whether the values are fixed-length or variable-length.
Does the values of the data type can be indexed.
How MySQL compares the value of a specific data type.
Numeric Data Types
You can find all SQL standard numeric types in MySQL including exact number data type and approximate numeric data types including integer, fixed-point and floating point. In addition, MySQL also supports BIT data type for storing bit field values. Numeric types can be signed or unsigned except the BIT type. The following table shows you the summary of numeric types in MySQL:
Numeric Types | Description |
---|---|
TINYINT | A very small integer |
SMALLINT | A small integer |
MEDIUMINT | A medium-sized integer |
INT | A standard integer |
BIGINT | A large integer |
DECIMAL | A fixed-point number |
FLOAT | A single-precision floating-point number |
DOUBLE | A double-precision floating-point number |
BIT | A bit field |
String Data Types
In MySQL, string can hold anything from plain text to binary data such as images and files. String can be compared and searched based on pattern matching by using the LIKE operator or . The following table shows you the string data types in MySQL:
String Types | Description |
---|---|
CHAR | A fixed-length non-binary (character) string |
VARCHAR | A variable-length non-binary string |
BINARY | A fixed-length binary string |
VARBINARY | A variable-length binary string |
TINYBLOB | A very small BLOB (binary large object) |
BLOB | A small BLOB |
MEDIUMBLOB | A medium-sized BLOB |
LONGBLOB | A large BLOB |
TINYTEXT | A very small non-binary string |
TEXT | A small non-binary string |
MEDIUMTEXT | A medium-sized non-binary string |
LONGTEXT | A large non-binary string |
ENUM | An enumeration; each column value may be assigned one enumeration member |
SET | A set; each column value may be assigned zero or more set members |
Date and Time Data Types
MySQL provides types for date and time as well as a combination of date and time. In addition, MySQL also provides data type for tracking the changes of a row in a table. If you just want to store the year without date and month, you can use YEAR data type. The following table illustrates the MySQL date and time data types:
Date and Time Types | Description |
---|---|
DATE | A date value in ‘CCYY-MM-DD’ format |
TIME | A time value in ‘hh:mm:ss’ format |
DATETIME | A date and time value in ‘CCYY-MM-DD hh:mm:ss’ format |
TIMESTAMP | A timestamp value in ‘CCYY-MM-DD hh:mm:ss’ format |
YEAR | A year value in CCYY or YY format |
Spatial Data Types
MySQL supports many spatial data types that contain various kind of geometrical and geographical values as shown in the following table:
Spatial Data Types | Description |
---|---|
GEOMETRY | A spatial value of any type |
POINT | A point (a pair of X Y coordinates) |
LINESTRING | A curve (one or more POINT values) |
POLYGON | A polygon |
GEOMETRYCOLLECTION | A collection of GEOMETRY values |
MULTILINESTRING | A collection of LINESTRING values |
MULTIPOINT | A collection of POINT values |
MULTIPOLYGON | A collection of POLYGON values |
原文連結:
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/2508/viewspace-2806112/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MYSQL 資料型別MySQL 資料型別
- MySQL 的資料型別MySql資料型別
- Mysql基本資料型別MySql資料型別
- 理解MySQL資料型別MySql資料型別
- MySQL的資料型別MySql資料型別
- Mysql 資料型別之整數型別MySQL 資料型別
- 【MySQL資料型別3之--字元型別】MySql資料型別字元
- [Mysql] 3.Mysql 資料型別MySQL 資料型別
- MySQL基礎之----資料型別篇(常用資料型別)MySql資料型別
- 【MySQL資料型別1之--數值型別】MySql資料型別
- MySQL資料型別DECIMAL用法MySql資料型別Decimal
- MySQL資料型別筆記MySql資料型別筆記
- mysql常見資料型別MySql資料型別
- mysql 常用的資料型別MySql資料型別
- MySQL入門--資料型別MySql資料型別
- mysql 資料型別TIMESTAMPMySQL 資料型別
- MySQL 資料型別詳解MySQL 資料型別
- 詳解MySQL資料型別MySql資料型別
- MySQL 資料型別 詳解MySQL 資料型別
- mysql資料型別小結MySql資料型別
- 5mysql資料型別MySql資料型別
- MySQL入門系列:MySQL資料型別MySql資料型別
- 【MySQL資料型別2之--日期時間型別】MySql資料型別
- Java 資料型別和 MySql 資料型別對應一覽表JavaMySQL 資料型別
- Mysql資料庫學習(二):資料型別(數值型別 日期和時間型別 字串型別)MySql資料庫資料型別字串
- MYSQL 資料型別儲存-數值型MySQL 資料型別
- mysql 配置注意事項、 mysql 資料型別MySQL 資料型別
- MySQL JSON資料型別操作MySqlJSON資料型別
- 06. MySQL的資料型別MySql資料型別
- 【MySQL】資料型別的基本用法MySql資料型別
- mysql 資料型別,字符集MySQL 資料型別
- MySQL(二) 資料庫資料型別詳解MySql資料庫資料型別
- MYSQL資料庫型別與JAVA型別對應關係MySql資料庫型別Java
- Mysql 基礎資料型別(無時間相關型別)MySql資料型別
- MySQL資料型別操作(char與varchar)MySql資料型別
- mysql整數資料型別深入解析MySql資料型別
- sql學習(mysql)(1)資料型別MySql資料型別
- Mysql支援的資料型別(總結)MySql資料型別