Home  >  Article  >  Database  >  Mysql数据类型_MySQL

Mysql数据类型_MySQL

WBOY
WBOYOriginal
2016-05-27 14:12:501094browse

bitsCN.com

整数类型:

默认是有符号的可以在定义时使用unsigned标识无符号

create table tbl_int(a tinyint unsigned,//无符号b tinyint//默认是有符号的);

定义显示宽度:数据类型(M)M表示显示的最小宽度,通过规定数据的显示宽度,达到统一显示的目的

      需要使用前导零填充,格式:数据类型(M) zerofill;

alter into tb1_int  add c tinyint(2) zerofill;

小数类型:

FLOAT默认精度位数6,7位左右,到了八位开始就会损失精度了  小数超过也会四舍五入
DOUBLE默认精度位数16,17位左右,超过就会损失精度   小数超过也会四舍五入

 控制数值的范围:

Type(M,D)M表示所有的数值位数(不包括小数点,符号)D表示允许的小数位数

create table num_1(A Float(5,2),B double(8,2));

浮点数支持科学计数法:
1.2345*10^3-----1.2345E3

 

 

 

日期时间类型:

 YEAR类型:

    给YEAR类型的字段赋值的方法:

                  1.使用4为字符串或者数字表示输入格式'yyyy'或者yyyy       

                                           

bitsCN.com
Statement:
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