MySQL数据类型

MySQL数据类型

-- 建立数据库
create database dbname;

create database if not exits `dbshop` default charset utf8;

-- 数据库列表
show databases;

-- 使用数据库 dbname
use dbname;

select CURRENT_USER,user(),database(),now();

-- 列出当前数据库中的所有信息内容
show tables

-- 建立一个学生信息表
create table t_user(
		id int(3) UNSIGNED ZEROFILL auto_increment,
		name varchar(10) not null,
		age tinyint UNSIGNED default 18,
		address varchar(50),
		primary key(id)
)engine=innodb charset=utf8 auto_increment=10

show tables;

-- 查看表有没有数据
select * from t_user;

insert into t_user value(null,'李四',22,'河南郑州');
insert t_user set name='张三丰',address='北京朝阳区';

# 删除表
drop table if exists `t_user`;

show tables

-- 数据类型
-- (1)数字类型
/* 整数 tinyint smallint MEDIUMINT int BIGINT */

/* 精度小数类型 double float numeric(p,s) decimal(p,s) */
create table tt1(
c1 tinyint(6) UNSIGNED ZEROFILL,
c2 bigint,
c3 decimal(6,2)
)

insert tt1 value(5,6,7);
insert tt1 value(5.5,6.6,7.7);
insert tt1 value(5.5,6.6,10000);

select * from tt1;

本人也正在学习,如有不当或错误之处,恳请您的指正,谢谢!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值