赞
踩
包括:bit、bool、 tinyint、smallint、 mediumint、int、bigint
包括:float、double、decimal
包括:char、varchar、tiny blob、blob、mediumblob、longblob、tinytext、text、mediumtext、longtext
包括:Date、DataTime、TimeStamp、Time、Year
暂不介绍,用的较少
create table 表名(字段名 数据类型);
show databases;
use test;
create table demo1(c1 tinyint);
show tables;
insert into 表名 values(值1,值2);
insert into demo1 values(-pow(2,7)),(pow(2,7)-1);
select 字段 from 表名
select c1 from demo1;
select * from 表名
select * from demo1;
表达最大长度2的7次方-1,就是-127~127
如果超出了可能报错,也可能截断
例如:
insert into demo1 values(pow(2,7));
insert into demo1 values(pow(2,8));
查看结果看看值
select c1 from demo1;
结果数据被截断了。
也有报错的情况,如下图
表达最大长度0~255,越界可能报错,也可能截断
创建多个字段的表
create table test3(a int,b int(5),c int(5) unsigned,d int(5) zerofill,e int(5) unsigned zerofill);
查看表
desc test3;
插入数据看看
insert into test3 values(1,1,1,1,1),(11,11,11,11,11),(12345,12345,12345,12345,12345);
查看数据
select * from test3;
查看表
show create table test3;
浮点类型(容易懵,注意看)
未完待续…
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。