1.创建数据库,创建英雄表添加对应的约束条件:
#创建数据库
create database if not exists db_zy default charset=utf8mb4;
#创建数据表
create table if not exists t_hero(
id int primary key auto_increment,
name varchar(50) not null unique,
gender enum("男", "女") default "男",
age int default 18,
weapon varchar(50) unique
)engine=innodb
2.插入80条数据:
insert into t_stu values(1, "孙悟空", "男",152,"金箍棒");
insert into t_stu values(2, "刘备", "男",45, "双管炮");
insert into t_stu values(3, "吕布", "男",44, "方天画戟");
insert into t_stu values(4, "赵云", "男",66, "龙胆亮银枪");
insert into t_stu values(5, "奎因", "女",30, "弓弩");
insert into t_stu values(6, "卡牌大师", "男",45, "卡牌");
insert into t_stu values(7, "河流之王", "男",100, "舌头");
insert into t_stu values(8, "蛮族之王", "男",50, "渴血战斧");
insert into t_stu values(9, "盖伦", "男",46, "大宝剑");
insert into t_stu values(10, "艾瑞利亚", "女", 29, "传世之剑");
insert into t_stu values(11, "锐雯", "女",28, "放逐之刃");
insert into t_stu values(12, "疾风剑豪", "男", 28, "无鞘之刃");
insert into t_stu values(13, "盲僧", "男", 30, "赤脚");
insert into t_stu values(14, "卡莎", "女", 26, "爱卡西亚暴雨");
insert into t_stu values(15, "提莫", "男", 10, "蘑菇");
insert into t_stu values(16, "小炮", "女", 12, "火炮");
insert into t_stu values(17, "铁男", "男", 66, "狼牙棒");
insert into t_stu values(18, "火男", "男", 48, "火元素");
insert into t_stu values(19, "璐璐", "女", 11, "魔法棒");
insert into t_stu values(20, "波比", "女", 14, "胜利之槌");
insert into t_stu values(21, "大发明家", "男", 66, "炮台");
insert into t_stu values(22, "奶妈", "女", 40, "回血杖");
insert into t_stu values(23, "厄斐琉斯", "男", 30, "飞轮");
insert into t_stu values(24, "宝石骑士", "男", 35, "宝石");
insert into t_stu values(25, "猪妹", "女", 36, "飞鞭");
insert into t_stu values(26, "寒冰射手", "女", 27,"弓箭");
insert into t_stu values(27, "丽桑卓", "女", 27, "冰");
insert into t_stu values(28, "加里奥", "男", 101, "翅膀");
insert into t_stu values(29, "天使", "女",200, "光剑");
insert into t_stu values(30, "剑姬", "女", 32, "击剑");
insert into t_stu values(31, "德玛西亚皇子", "男", 32, "旗");
insert into t_stu values(32, "尼拉", "女", 22, "鞭子");
insert into t_stu values(33, "光辉", "女", 32, "光盾");
insert into t_stu values(34, "霞", "女", 23, "飞羽");
insert into t_stu values(35, "洛", "男", 24, "耀光");
insert into t_stu values(36, "烬", "男", 35, "左轮");
insert into t_stu values(37, "黑暗之女", "女", 12, "小熊");
insert into t_stu values(38, "牛头酋长", "男", 56, "牛角");
insert into t_stu values(39, "战争女神", "女", 30, "轮子剑");
insert into t_stu values(40, "远古恐惧", "男", 120, "稻草");
insert into t_stu values(41, "雪原双子", "男", 10, "雪人");
insert into t_stu values(42, "符文法师", "男", 60, "符文");
insert into t_stu values(43, "无极剑圣", "男", 45, "无极剑");
insert into t_stu values(44, "祖安怒兽", "男", 100, "狼爪");
insert into t_stu values(45, "塞恩", "男", 101, "暗影战斧");
insert into t_stu values(46, "武器大师", "男", 34, "路灯");
insert into t_stu values(47, "莫甘娜", "女", 131, "黑暗魔法");
insert into t_stu values(48, "辛吉德", "男", 70, "毒药罐");
insert into t_stu values(49, "时光守护者", "男", 80, "时光机");
insert into t_stu values(50, "伊芙琳", "女", 45, "毒刺");
insert into t_stu values(51, "老鼠", "男", 12, "毒弓弩");
insert into t_stu values(52, "死歌", "男", 102, "吟唱");
insert into t_stu values(53, "科加斯", "男", 50, "牙齿");
insert into t_stu values(54, "阿木木", "男", 9, "绷带");
insert into t_stu values(55, "龙龟", "男", 1000, "龟壳");
insert into t_stu values(56, "冰鸟", "女", 106, "冰刺");
insert into t_stu values(57, "卡萨丁", "男", 61, "虚空剑");
insert into t_stu values(58, "船长", "男", 56, "橘子");
insert into t_stu values(59, "机器人", "男", 54, "钩子");
insert into t_stu values(60, "风女", "女", 21, "风");
insert into t_stu values(61, "莫菲特", "男", 60, "石头");
insert into t_stu values(62, "蒙多", "男", 62, "菜刀");
insert into t_stu values(63, "飞机", "男", 33, "飞机");
insert into t_stu values(64, "卡特", "女", 30, "匕首");
insert into t_stu values(65, "狗头", "男", 56, "沙漠斧头");
insert into t_stu values(66, "小丑", "男", 41, "盒子");
insert into t_stu values(67, "豹女", "女", 32, "标枪");
insert into t_stu values(68, "古拉加斯", "男", 45, "酒桶");
insert into t_stu values(69, "EZ", "男", 20, "弹幕");
insert into t_stu values(70, "慎", "男", 40, "光刀");
insert into t_stu values(71, "凯南", "男", 23, "电镖");
insert into t_stu values(72, "狂战士", "男", 51, "斧头");
insert into t_stu values(73, "深渊巨口", "男", 26, "大嘴");
insert into t_stu values(74, "德邦", "男", 36, "亮银枪");
insert into t_stu values(75, "吸血鬼", "男", 38, "吸血");
insert into t_stu values(76, "厄加特", "男", 38, "战车");
insert into t_stu values(77, "琴女", "女", 29, "琴");
insert into t_stu values(78, "巨魔", "男", 66, "冰棒");
insert into t_stu values(79, "蛇女", "女", 47, "毒牙");
insert into t_stu values(80, "女警", "女", 34, "狙击枪");
select * from t_hero;
ALTER TABLE t_hero ADD nickname varchar(50) unique;
ALTER TABLE t_hero ADD address varchar(50);
alter table t_hero drop address;
alter table t_hero rename t_super;