# 如果yonghu表已经存在 则删除此表
drop table if exists `yonghu`;
# 创建用户表
create table yonghu (
# 列名称为id 'primary key'代表为主键 'auto_increment'代表自增
id int(11) primary key auto_increment,
# 列名称为ming_cheng varchar(20)表示为字符串 20表示最多可以存20个字符
ming_cheng varchar(20)
);
# 显示当前数据库所有的表
show tables;
# 新增三条数据
insert into yonghu(ming_cheng) values ('用户1'), ('用户2'), ('用户3');
# 查询yonghu表的所有数据
select * from yonghu;
# 查询yonghu表 id大于2的数据
select * from yonghu where id > 2;
# 查询yonghu表 id大于2的 ming_cheng列数据
select ming_cheng from yonghu where id > 2;
MySql基础-创建表-新增数据
最新推荐文章于 2023-05-29 16:43:35 发布