当前位置:网站首页>SQL is used for field data types in various databases
SQL is used for field data types in various databases
2022-06-25 18:36:00 【ookaoooo】
Microsoft Access、MySQL and SQL Server The type and range of data used .
Microsoft Access data type
| data type | describe | Storage |
|---|---|---|
| Text | For text or a combination of text and numbers . | most 255 Characters . |
| Memo | Memo For a larger number of texts . Maximum storage 65,536 Characters . notes : Be able to memo Field to sort . But they are searchable . | |
| Memo | Memo For a larger number of texts . Maximum storage 65,536 Characters . notes : Be able to memo Field to sort . But they are searchable . | |
| Byte | allow 0 To 255 The number of . | 1 byte |
| Integer | Allow between -32,768 And 32,767 All the numbers between . | 2 byte |
| Long | Allow between -2,147,483,648 And 2,147,483,647 All the numbers between . | 4 byte |
| Single | Single precision floating point . Handle most decimals . | 4 byte |
| Double | Double precision floating point . Handle most decimals . | 8 byte |
| Currency | For money . Support 15 Bitwise element , Plus 4 Decimal place . Tips : You can choose which currency to use . | 8 byte |
| AutoNumber | AutoNumber Fields automatically assign numbers to each record , Usually from 1 Start . | 4 byte |
| Date/Time | For date and time | 8 byte |
| Yes/No | Logical fields , It can be shown as Yes/No、True/False or On/Off. In the code , Use a constant True and False ( Equivalent to 1 and 0). notes :Yes/No The... Is not allowed in the field Null value | 1 The bit |
| Ole Object | Can store pictures 、 Audio 、 Video or something BLOBs(Binary Large OBjects). | most 1GB |
| Hyperlink | Contains links to other files , Including web pages . | |
| Lookup Wizard | Allows you to create a list of options that can be selected from the drop-down list . | 4 byte |
MySQL data type
stay MySQL in , There are three main types :Text( Text )、Number( Numbers ) and Date/Time( date / Time ) type .
Text type :
| data type | describe |
|---|---|
| CHAR(size) | Saves a fixed length string ( Can contain letters 、 Numbers and special characters ). Specify the length of the string in parentheses . most 255 Characters . |
| VARCHAR(size) | Save variable length strings ( Can contain letters 、 Numbers and special characters ). Specify the maximum length of the string in parentheses . most 255 Characters . notes : If the length of the value is greater than 255, Is converted to TEXT type . |
| TINYTEXT | The maximum storage length is 255 Character string . |
| TEXT | The maximum storage length is 65,535 Character string . |
| BLOB | be used for BLOBs(Binary Large OBjects). Store up to 65,535 Bytes of data . |
| MEDIUMTEXT | The maximum storage length is 16,777,215 Character string . |
| MEDIUMBLOB | be used for BLOBs(Binary Large OBjects). Store up to 16,777,215 Bytes of data . |
| LONGTEXT | The maximum storage length is 4,294,967,295 Character string . |
| LONGBLOB | be used for BLOBs (Binary Large OBjects). Store up to 4,294,967,295 Bytes of data . |
| ENUM(x,y,z,etc.) | Allows you to enter a list of possible values . Can be in ENUM List the largest 65535 It's worth . If there is no inserted value in the list , Then insert a null value . notes : The values are sorted in the order you enter . You can enter the possible values in this format : ENUM('X','Y','Z') |
| SET | And ENUM similar , The difference is ,SET It can only contain at most 64 List items and SET Can store more than one choice . |
Number type :
| data type | describe |
|---|---|
| TINYINT(size) | Signed -128 To 127 , Unsigned 0 To 255. |
| SMALLINT(size) | Signed range -32768 To 32767, Unsigned 0 To 65535, size The default is 6. |
| MEDIUMINT(size) | Signed range -8388608 To 8388607, The unsigned range is 0 To 16777215. size The default is 9 |
| INT(size) | Signed range -2147483648 To 2147483647, The unsigned range is 0 To 4294967295. size The default is 11 |
| BIGINT(size) | The signed range is -9223372036854775808 To 9223372036854775807, The unsigned range is 0 To 18446744073709551615.size The default is 20 |
| FLOAT(size,d) | A small number with a floating decimal point . stay size The parameter specifies the maximum number of digits to be displayed . stay d The parameter specifies the maximum number of digits to the right of the decimal point . |
| DOUBLE(size,d) | A large number with a floating decimal point . stay size The parameter shows the fixed maximum number of digits . stay d The parameter specifies the maximum number of digits to the right of the decimal point . |
| DECIMAL(size,d) | Stored as a string DOUBLE type , Allow fixed decimal point . stay size The parameter specifies the maximum number of digits to be displayed . stay d The parameter specifies the maximum number of digits to the right of the decimal point . |
Be careful : The above size It doesn't represent the specific length stored in the database , Such as int(4) It's not just storage 4 A number of lengths .
actually int(size) It doesn't matter how much storage space it takes .int(3)、int(4)、int(8) It's all on disk 4 btyes Storage space . It's just that the way it's displayed to users is a little different ,int(M) Follow int The data type is the same .
for example :
1、int The value of is 10 ( Appoint zerofill)
int(9) The result is 000000010
int(3) The result is 010
It's just that the length of the display is not the same All take up four bytes of space Date type :
| data type | describe |
|---|---|
| DATE() | date . Format :YYYY-MM-DD notes : The scope of support is from '1000-01-01' To '9999-12-31' |
| DATETIME() | * A combination of date and time . Format :YYYY-MM-DD HH:MM:SS notes : The scope of support is from '1000-01-01 00:00:00' To '9999-12-31 23:59:59' |
| TIMESTAMP() | * Time stamp .TIMESTAMP Value usage Unix An era ('1970-01-01 00:00:00' UTC) Seconds to date to store . Format :YYYY-MM-DD HH:MM:SS notes : The scope of support is from '1970-01-01 00:00:01' UTC To '2038-01-09 03:14:07' UTC |
| TIME() | Time . Format :HH:MM:SS notes : The scope of support is from '-838:59:59' To '838:59:59' |
| YEAR() | 2 Bit or 4 Bit format year . notes :4 Value allowed by bit format :1901 To 2155.2 Value allowed by bit format :70 To 69, From 1970 To 2069. |
* Even if DATETIME and TIMESTAMP Return the same format , They work in very different ways . stay INSERT or UPDATE Querying ,TIMESTAMP Automatically set itself to the current date and time .TIMESTAMP Also accept different formats , such as YYYYMMDDHHMMSS、YYMMDDHHMMSS、YYYYMMDD or YYMMDD.
SQL Server data type
String type :
| data type | describe | Storage |
|---|---|---|
| char(n) | Fixed length string . most 8,000 Characters . | Defined width |
| varchar(n) | Variable length string . most 8,000 Characters . | 2 bytes + number of chars |
| varchar(max) | Variable length string . most 1,073,741,824 Characters . | 2 bytes + number of chars |
| text | Variable length string . most 2GB Text data . | 4 bytes + number of chars |
| nchar | Fixed length Unicode character string . most 4,000 Characters . | Defined width x 2 |
| nvarchar | Variable length Unicode character string . most 4,000 Characters . | |
| nvarchar(max) | Variable length Unicode character string . most 536,870,912 Characters . | |
| ntext | Variable length Unicode character string . most 2GB Text data . | |
| bit | allow 0、1 or NULL | |
| binary(n) | Fixed length binary string . most 8,000 byte . | |
| varbinary | Variable length binary string . most 8,000 byte . | |
| varbinary(max) | Variable length binary string . most 2GB. | |
| image | Variable length binary string . most 2GB. |
Number type :
| data type | describe | Storage | |
|---|---|---|---|
| tinyint | Allow from 0 To 255 All the numbers of . | 1 byte | |
| smallint | Allow between -32,768 And 32,767 All the numbers of . | 2 byte | |
| int | Allow between -2,147,483,648 And 2,147,483,647 All the numbers of . | 4 byte | |
| bigint | Allow between -9,223,372,036,854,775,808 And 9,223,372,036,854,775,807 All numbers between . | 8 byte | |
| decimal(p,s) | Fixed precision and scale figures .</br> Allow from -10^38 +1 To 10^38 -1 Number between .</br>p Parameter indicates the maximum number of bits that can be stored ( To the left and right of the decimal point ).p Must be 1 To 38 Between the value of the . The default is 18.</br>s Parameter indicates the maximum number of digits stored to the right of the decimal point .s Must be 0 To p Between the value of the . The default is 0. | 5-17 byte | |
| numeric(p,s) | Fixed precision and scale figures .</br> Allow from -10^38 +1 To 10^38 -1 Number between .</br>p Parameter indicates the maximum number of bits that can be stored ( To the left and right of the decimal point ).p Must be 1 To 38 Between the value of the . The default is 18.</br>s Parameter indicates the maximum number of digits stored to the right of the decimal point .s Must be 0 To p Between the value of the . The default is 0. | 5-17 byte | |
| smallmoney | Be situated between -214,748.3648 And 214,748.3647 Currency data between . | 4 byte | |
| money | Be situated between -922,337,203,685,477.5808 And 922,337,203,685,477.5807 Currency data between . | 8 byte | |
| float(n) | from -1.79E + 308 To 1.79E + 308 The floating precision of digital data .</br>n Parameter indicates that the field saves 4 Byte or 8 byte .float(24) preservation 4 byte , and float(53) preservation 8 byte .n The default value of is 53. | 4 or 8 byte | |
| real | from -3.40E + 38 To 3.40E + 38 The floating precision of digital data . | 4 byte |
Date type :
| data type | describe | Storage |
|---|---|---|
| datetime | from 1753 year 1 month 1 Japan To 9999 year 12 month 31 Japan , Accuracy of 3.33 millisecond . | 8 byte |
| datetime2 | from 1753 year 1 month 1 Japan To 9999 year 12 month 31 Japan , Accuracy of 100 nanosecond . | 6-8 byte |
| smalldatetime | from 1900 year 1 month 1 Japan To 2079 year 6 month 6 Japan , Accuracy of 1 minute . | 4 byte |
| date | Store date only . from 0001 year 1 month 1 Japan To 9999 year 12 month 31 Japan . | 3 bytes |
| time | Storage time only . Accuracy of 100 nanosecond . | 3-5 byte |
| datetimeoffset | And datetime2 identical , Plus time zone offset . | 8-10 byte |
| timestamp | Store unique numbers , Whenever a line is created or modified , The number will be updated .timestamp Value based on internal clock , It doesn't correspond to the real time . Each watch can only have one timestamp Variable . |
Other data types :
| data type | describe | |
|---|---|---|
| sql_variant | Store the most 8,000 Byte data of different data types , except text、ntext as well as timestamp. | |
| uniqueidentifier | Store globally unique identifier (GUID). | |
| xml | Storage XML Format data . most 2GB. | |
| cursor | Store references to pointers used for database operations . | |
| table | Save the result set , For later processing . |
边栏推荐
猜你喜欢

正则表达式总结
![Development status of China's hydrotalcite industry in 2020 and analysis of major enterprises: the market scale is rapidly increasing, and there is a large space for domestic substitution [figure]](/img/2c/05f2aa467edb76095e30a117adc251.jpg)
Development status of China's hydrotalcite industry in 2020 and analysis of major enterprises: the market scale is rapidly increasing, and there is a large space for domestic substitution [figure]

【深入理解TcaplusDB技术】如何实现Tmonitor单机安装

Anaconda download Tsinghua source
![Analysis on the development trend of China's intense pulsed light equipment industry in 2021: the market scale is growing, and the proportion of imported brands is large [figure]](/img/15/4477a850044136bb4b1ee92ab6df45.jpg)
Analysis on the development trend of China's intense pulsed light equipment industry in 2021: the market scale is growing, and the proportion of imported brands is large [figure]

03 runtime data area overview and threads

Detailed explanation of oauth2 - Introduction (I)

【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩

Tiger DAO VC产品正式上线,Seektiger生态的有力补充

Current situation and development suggestions of China's green PPP project industry: the investment scale is expanding, and the existing problems need to be improved to further promote the healthy dev
随机推荐
Tiger DAO VC产品正式上线,Seektiger生态的有力补充
网络安全检测与防范 练习题(三)
[deeply understand tcapulusdb technology] create a game area for document acceptance
【深入理解TcaplusDB技术】TcaplusDB机型
LeetCode 3. Longest substring without repeated characters & sliding window
Oriental Wealth function (the most complete edition of Childe Yong)
Training of long and difficult sentences in postgraduate entrance examination day87
Training of long and difficult sentences in postgraduate entrance examination day84
Apifox简单了解——WEB端测试的集大成者
Redis6
Idea annotation color modification method (clear)
Dell r530 built in hot spare status change description
一晚上做了一个xpath终结者:xpath-helper-plus
electron 基础项目搭建 &&主线程和渲染线程的通信
[in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance doc
Some recursive and iterative problem solving ideas of binary tree (clear and easy to understand)
解决sublime Text3 package control 无法安装插件问题
2021 development status of China's cloud game industry and analysis of major service providers: Although cloud games are still in their infancy, the market prospect is huge [figure]
正则表达式总结
solidity获取季度时间