Giter VIP home page Giter VIP logo

Comments (1)

wuye1200 avatar wuye1200 commented on August 30, 2024

数据类型

image

1.整数数据类型及其取值范围:

类型 说明 存储需求(取值范围)
tinyint 很小整数 1字节([0255]、[-128127]); 255=2^8-1;127=2^7-1
smallint 小整数 2字节(065535、-3276832767) ;65535=2^16-1
mediumint 中等 3字节(0~16777215) ;16777215=2^24-1
int(integer) 普通 4字节(0~4294967295) ;4294967295=2^32-1
bigint 大整数 8字节(0~18446744073709551615);18446744073709551615=2^64-1

浮点数&定点数:

类型名称 说明 存储需求
float 单精度浮点数 4字节
double 双精度浮点数 8字节
decimal 压缩的“严格”定点数 M+2字节

2.时间/日期类型:

year范围:19012155;
time格式:‘HH:MM:SS’(如果省略写,并且没有冒号,则默认最右起2位为秒,再到分,最后到时);
插入系统当前时间:insert into 表名 values(current_date()),(now());
date类型:‘YYYY-MM-DD’;
datetime(日期+时间):‘YYYY-MM-DD HH:MM:SS’或‘YYYYMMDDHHMMSS’,取值范围:‘1000-01-01 00:00:00’
‘9999-12-31 23:59:59’;
timestamp格式同datetime,但在存储时需要4个字节(datetime需要8字节),并且以UTC(世界标准时间)进行存储(即timestamp会随设置的时区而变化,而datetime存储的绝不会变化);timestamp的范围:1970-2037。

3.字符串类型:

text类型:tinytext、text、mediumtext、longtext;

类型 范围
tinytext 255=2^8-1
text 65535=2^16-1
mediumtext 16777215=2^24-1
longtext 4294967295=4GB=2^32-1

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.