zoukankan      html  css  js  c++  java
  • mysql数据类型

    常见数据类型有:

    整数:tinyint、smallint、mediumint、int、bigint

    浮点数:float、double

    定点数:decimal

    字符串:char、varchar、tinytext、text、mediumtext、longtext

    日期:date、datetime、timestamp、year、time

    整数的申明方式:

    类型 声明方式
    tinyint

    TINYINT[(M)] [UNSIGNED] [ZEROFILL]  M默认为4

    smallint

    SMALLINT[(M)] [UNSIGNED] [ZEROFILL] M默认为6

    mediumint

    MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL] M默认为9

    int

    INT[(M)] [UNSIGNED] [ZEROFILL]   M默认为11

    bigint

    BIGINT[(M)] [UNSIGNED] [ZEROFILL] M默认为20

    注:这里的M代表的并不是存储在数据库中的具体的长度,而是指明int的最小显示位数,并且该值只有在指明了zerofill之后才会生效。

    mysql> create table t (t int(3));
    Query OK, 0 rows affected (0.02 sec)
    
    mysql> insert into t values(11),(111),(1111);
    Query OK, 3 rows affected (0.00 sec)
    Records: 3  Duplicates: 0  Warnings: 0
    
    mysql> select * from t;
    +------+
    | t    |
    +------+
    |   11 |
    |  111 |
    | 1111 |
    +------+
    3 rows in set (0.00 sec)
    
    mysql> alter table t change t t int(3) zerofill;
    Query OK, 3 rows affected (0.06 sec)
    Records: 3  Duplicates: 0  Warnings: 0
    
    mysql> select * from t;
    +------+
    | t    |
    +------+
    |  011 |
    |  111 |
    | 1111 |
    +------+
    3 rows in set (0.00 sec)
  • 相关阅读:
    docker数据卷
    docker容器的启动、停止、运行、导入、导出、删除
    docker镜像的获取、创建、修改、删除、导入操作
    docker使用-spark安装
    python爬虫-3 解析库
    python爬虫-2 requests使用
    NLP-HMM
    NLP-中文分词-预处理
    python爬虫-1环境安装
    学习笔记3
  • 原文地址:https://www.cnblogs.com/jade640/p/7169651.html
Copyright © 2011-2022 走看看