Home Database Mysql Tutorial MYSQL列类型参考_MySQL

MYSQL列类型参考_MySQL

Jun 01, 2016 pm 01:57 PM
information

本附录介绍MySQL提供的每种列类型。关于利用每种类型的详细说明请参阅第2 章。除非另有说明,否则所列出的类型早在MySQL3.21.0 中就已经有了。
    按下列约定给出类型名说明:
    方括号( [ ]) 可选信息。
    M 最大显示宽度。除非另有说明,否则M 应该是一个1到255 之间的整数。
    D 有小数部分的类型的小数位数。D 为一个0 到30 之间的整数。D 应该小于等于M - 2。否则,M 的值将调整为D + 2。
    在ODBC 术语中,M 和D 称为“精度”和“小数位数”。
    为了描述每种类型,提供下列一个或多个信息:
    说明 该类型的简短说明。
    允许的属性 在CREATE TABLE 或ALTER TABLE 语句中与该类型相关的可选属性关键字。属性按字母顺序列出,但这个顺序并不一定与CREATE TABLE 或ALTE R TABLE 中使用的顺序相对应。关于这些语句的语法请参阅附录D。每种列类型在说明中列出的属性为通用属性之外的属性。
    允许的长度 串类型的列值所允许的最大长度。
    取值范围 对于数值或日期与时间类型,该类型可表示的值的范围。对于整数数值类型,给出两个取值范围,因为整数列可以是有符号或无符号的,有符号或无符号的取值范围是不同的。
    零值 对于日期和时间类型,如果将非法值插入该列,则存入一个“零”值。
    缺省值 类型说明中不明确给出D E FA U LT 属性时的缺省值。
    存储需求 存储该类型的值所需的字节数。对于有的类型,这个值是固字的。而这个值在有些类型中根据存放在列中的值的不同是可变的。
    比较 对于串类型,比较是否是区分大小写的。这对排序和索引有效,因为这些操作根据比较进行的。
    同义词 该类型名的同义词。
    注释 关于该类型的一些杂项说明。
    通用属性 有的属性对所有类型或对于几乎所有类型都适用。它们列在这里,而不是列在每种类型的说明中。可对任何类型指定NULL 或NOT NULL 属性。还可对所有类型指定D E FA U LT default_value。

MYSQL数值类型

    MySQL提供了整数和浮点数的数值类型。可根据所要表示的值的范围选择相应的类型。
    对于整数类型,如果指定了AUTO_INCREMENT 属性,则列必须为PRIMARY KEY 或UNIQUE 索引。将NULL 插入AUTO_INCREMENT 列将会插入一个大于该列中当前最大值的值。如果指定了UNSIGNED 属性,则相应的整数类型不允许取负值。
    如果指定了ZEROFILL 属性,则用前导零填充数值类型值以达到列的显示宽度。
    1. TINYINT[(M)]
    说明:非常小的整数
    允许的属性:AUTO _ I N C R E M E N T, UNSIGNED, ZEROFILL
    取值范围:-128 到127(-27 到27-1),或者如果为U N S I G N E D,则0 到2 5 5(0 到2 8-1)
    缺省值:如果列可为NULL;则为NULL;如果列为NOT NULL,则为0
    存储需求:1字节
    2. SMALLINT[(M)]
    说明:小整数
    允许的属性:AUTO _ I N C R E M E N T, UNSIGNED, ZEROFILL
    取值范围:-32768 到3 27 6 7(-215 到215-1),或者如果为U N S I G N E D,则0 到6 5 5 3 5 (0 到216-1)
    缺省值:如果列可为NULL;则为NULL;如果列为NOT NULL,则为0
    存储需求:2 字节
    3. MEDIUMINT[(M)]
    说明:中等大小的整数
    允许的属性:AUTO _ I N C R E M E N T, UNSIGNED, ZEROFILL
    取值范围:-8388608 到8 3 8 8 6 07(-22 3 到22 3-1),或者如果为U N S I G N E D,则0 到16 7 7 2 15(0 到22 4-1)
    缺省值:如果列可为NULL,则为NULL;如果列为NOT NULL,则为0
    存储需求:4 字节
    4. INT[(M)]
    说明:标准大小的整数
    允许的属性:AUTO _ I N C R E M E N T, UNSIGNED, ZEROFILL
    取值范围:-2147483648 到2 14 7 4 8 3 6 4 7(-231到2 3 1-1),或者如果为U N S I G N E D,则0 到4 2 9 4 9 6 7 2 9 5(0 到2 3 2-1)
    缺省值:如果列为NULL,则为NULL;如果列为NOT FULL,则为0
    存储需求:4 字节
    同义词:I N T E G E R [(M)]
    5. BIGINT[(M)]
    说明:大整数
    允许的属性:AUTO _ I N C R E M E N T, UNSIGNED, ZEROFILL
    取值范围:-9223372036854775808 到9 2 2 3 3 7 2 0 3 6 8 5 4 7 7 5 8 07(-263 到2 6 3-1),或者如果为U N S I G N E D,则0 到18 4 4 6 7 4 4 07 3 7 0 9 5 5 16 15(0 到26 4 -1)
    缺省值:如果列可为NULL,则为NULL;如果列为NOT NULL,则为0
    存储需求:8 字节
    6. FLOAT [(M, D)]
    说明:小浮点数;单精度(精度小于D O U B L E)
    允许的属性:Z E R O F I L L
    取值范围:最小非零值为±1.75494351E -38; 最大非零值为±3 . 4 0 2 8 2 3 4 6 6 E + 3 8
    缺省值:如果列可为NULL,则为NULL;如果列为NOT NULL,则为0
    存储需求:4 字节
    同义词:MySQL3.23 版以前,FLOAT(4) 为具有缺省M 和D 值的FLOAT的同义词。
    注释:在MySQL3.23 以后,FLOAT(4) 为真浮点类型(值存储为硬件所允许的完整精度,而不四舍五入为缺省的小数位数)
    7. DOUBLE[(M, D)]
    说明:大浮点数;双精度(比FLOAT更精确)
    允许的属性:Z E R O F I L L
    取值范围:最小非零值为±2 . 2 2 5 07 3 8 5 8 5 07 2 0 14 E -308; 最大非零值为±1。7 9 7 6 9 3 13 - 4 8 6 2 3 15 7 E + 3 0 8
    缺省值:如果列可为NULL,则为NULL;如果列为NOT NULL,则为0
    存储需求:8 字节
    同义词:DOUBLE PRECISION[(M, D)] 和R E A L [ (M, D)] 为D O U B L E [(M, D)] 的同义词。MySQL3.23 版以前,FLOAT(8) 为具有缺省M 和D 值的FLOAT的同义词。
    注释:在MySQL3.23 以后,FLOAT(8) 为真浮点类型(值存储为硬件所允许的完整精度,而不四舍五入为缺省的小数位数)。
    8. DECIMAL(M, D)
    说明:存储为串的浮点数(每位数字、小数点或“-”号都占1字节)。
    允许的属性:Z E R O F I L L
    取值范围:最大取值范围与DOUBLE 相同;给定DECIMAL 类型的有效取值范围由M和D 决定。如果D 为零,则列值无小数点或小数部分。
    缺省值:如果列可为NULL,则为NULL,如果列为NOT NULL,则为0
    存储需求:对于MySQL3.23 前的版本,为M 字节,而MySQL3.23 以后的版本,为M + 2 字节。
    同义词:N U M E R I C (M, D)
    注释:在MySQL3.23 以后,M 的值为符合ANSI SQL 标准,不包括符号字符或小数点所占的字节数。

MYSQL串类型

    MySQL的串类型常用来存储文本,它不但是通用的而且还能存储任何数据。可用串类型来存储最大长度可变的值,而且可以选择在处理值时是否区分大小写。
    1. CHAR(M)
    说明:0 到M 字节长的定长字符串。在MySQL3.23 版以前,M 应该为一个1到255 之间的整数。而MySQL3.23 版以后,M 应该为一个0 到255 之间的整数。短于M 个字符的串存储进右边补空格。长于M 个字符的串存储时剪断为长度是M 的串。在检索值时,去掉后跟的空格。
    允许的属性:B I N A RY

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to remove author and last modified information in Microsoft Word How to remove author and last modified information in Microsoft Word Apr 15, 2023 am 11:43 AM

Microsoft Word documents contain some metadata when saved. These details are used for identification on the document, such as when it was created, who the author was, date modified, etc. It also has other information such as number of characters, number of words, number of paragraphs, and more. If you might want to remove the author or last modified information or any other information so that other people don't know the values, then there is a way. In this article, let’s see how to remove a document’s author and last modified information. Remove author and last modified information from Microsoft Word document Step 1 – Go to

How to get the GPU in Windows 11 and check the graphics card details How to get the GPU in Windows 11 and check the graphics card details Nov 07, 2023 am 11:21 AM

Using System Information Click Start and enter System Information. Just click on the program as shown in the image below. Here you can find most of the system information, and one thing you can find is graphics card information. In the System Information program, expand Components, and then click Show. Let the program gather all the necessary information and once it's ready, you can find the graphics card-specific name and other information on your system. Even if you have multiple graphics cards, you can find most content related to dedicated and integrated graphics cards connected to your computer from here. Using the Device Manager Windows 11 Just like most other versions of Windows, you can also find the graphics card on your computer from the Device Manager. Click Start and then

The single-view NeRF algorithm S^3-NeRF uses multi-illumination information to restore scene geometry and material information. The single-view NeRF algorithm S^3-NeRF uses multi-illumination information to restore scene geometry and material information. Apr 13, 2023 am 10:58 AM

Current image 3D reconstruction work usually uses a multi-view stereo reconstruction method (Multi-view Stereo) that captures the target scene from multiple viewpoints (multi-view) under constant natural lighting conditions. However, these methods usually assume Lambertian surfaces and have difficulty recovering high-frequency details. Another approach to scene reconstruction is to utilize images captured from a fixed viewpoint but with different point lights. Photometric Stereo methods, for example, take this setup and use its shading information to reconstruct the surface details of non-Lambertian objects. However, existing single-view methods usually use normal map or depth map to represent the visible

How to share contact details with NameDrop: How-to guide for iOS 17 How to share contact details with NameDrop: How-to guide for iOS 17 Sep 16, 2023 pm 06:09 PM

In iOS 17, there's a new AirDrop feature that lets you exchange contact information with someone by touching two iPhones. It's called NameDrop, and here's how it works. Instead of entering a new person's number to call or text them, NameDrop allows you to simply place your iPhone near their iPhone to exchange contact details so they have your number. Putting the two devices together will automatically pop up the contact sharing interface. Clicking on the pop-up will display a person's contact information and their contact poster (you can customize and edit your own photos, also a new feature of iOS17). This screen also includes the option to "Receive Only" or share your own contact information in response.

How NameDrop works on iPhone (and how to disable it) How NameDrop works on iPhone (and how to disable it) Nov 30, 2023 am 11:53 AM

In iOS17, there is a new AirDrop feature that allows you to exchange contact information with someone by touching two iPhones at the same time. It's called NameDrop, and here's how it actually works. NameDrop eliminates the need to enter a new person's number to call or text them so they have your number, you can simply hold your iPhone close to their iPhone to exchange contact information. Putting the two devices together will automatically pop up the contact sharing interface. Clicking on the popup will display a person's contact information and their contact poster (a photo of your own that you can customize and edit, also new to iOS 17). This screen also includes "Receive Only" or share your own contact information in response

What's the reason for the delay in receiving messages on WeChat? What's the reason for the delay in receiving messages on WeChat? Sep 19, 2023 pm 03:02 PM

The reason for the delay in WeChat receiving information may be network problems, server load, version problems, device problems, message sending problems or other factors. Detailed introduction: 1. Network problems. The delay in receiving information on WeChat may be related to the network connection. If the network connection is unstable or the signal is weak, it may cause delays in information transmission. Please ensure that the mobile phone is connected to a stable network and the network signal strength is good. ; 2. Server load. When the WeChat server load is high, it may cause delays in information transmission, especially during busy periods or when a large number of users use WeChat at the same time, etc.

iOS 17 NameDrop: How to Easily Share Your Contact Information on iPhone iOS 17 NameDrop: How to Easily Share Your Contact Information on iPhone Jul 30, 2023 pm 05:18 PM

Apple has introduced a very fast (if not the fastest) way to share your contact information with another iPhone via NameDrop. Here's everything you need to know. What is NameDrop? iOS 17 introduces NameDrop, a revolutionary feature that leverages contact posters. These personalized cards can be created for yourself and other contacts and will appear whenever you make a call. With multiple customizable options such as photos, Memojis, monograms, and more, you can tailor your contact poster to match your personality using your preferred color scheme and fonts. NameDrop automatically shares your poster when your iPhone is in close proximity to other users, allowing both parties to effortlessly

What is the unit for transmitting information in a computer network? What is the unit for transmitting information in a computer network? Dec 07, 2020 pm 05:26 PM

The transmission of information in computer networks is based on "words"; words are the basic unit of data transmission. Computer networks have two main functions: data communication and resource sharing, and the information transmitted in data communication is expressed in the form of binary data. Data communication is a communication method and communication service that uses data transmission technology to transfer data information between two terminals according to a certain communication protocol.

See all articles