Mysql——创建数据库,对表的创建及字段定义、数据录入、字段增加及删除、重命名表。

一.创建数据库

create database db_classics default charset=utf8mb4;//创建数据库
use db_classics;//使用该数据库

二.对表的创建及字段定义

create table if not exists t_hero (
id int primary key auto_increment,
Name varchar(100) not null unique,
Nickname varchar(100) not null unique,
Age int not null unique,
Address text not null unique,
club varchar(100) not null unique,
weapon varchar(100) not null unique,
bloc varchar(100) not null unique
);

 三.数据录入

insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(1,“孙悟空”,”齐天大圣”,600,”花果山水帘洞”,”取经大队”,”金箍棒”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(2,“唐僧”,”金蝉子”,30,”东土大唐”,”取经大队”,”禅杖”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(3,“猪八戒”,”天蓬元帅”,800,”高老庄”,”取经大队”,”九齿钉耙”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(4,“沙悟净”,”卷帘大将”,700,”流沙河”,”取经大队”,”降妖宝杖”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(5,“玉帝”,”玉皇大帝”,30000,”天庭”,”神界”,”开天斧”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(6,“白龙马”,”龙王三太子”,500,”西海龙宫”,”取经大队”,”龙泉宝剑”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(7,“如来佛祖”,”释迦牟尼尊者”,99999,”西天灵山”,”佛教”,”舍利子”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(8,“观影菩萨”,”观世音菩萨”,10000,”南海普陀落伽山潮音洞”,”佛教”,”玉净瓶”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(9,“黑熊怪”,”黑风怪”,500,”黑风洞”,”妖怪”,”黑缨枪”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(10,“红孩儿”,”圣婴大王”,400,”钻头号山”,”妖界”,”火尖枪”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(11,“牛魔王”,”大力牛魔王”,2000,”翠云山芭蕉洞”,”妖界”,”混铁棍”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(12,“铁扇公主”,”罗莎女”,1800,”翠云山芭蕉洞”,”妖界”,”芭蕉扇”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(13,“镇元子”,”镇元大仙”,20000,”五庄观”,”神界”,”拂尘”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(14,“菩提老祖”,”须菩提祖师”,20000,”灵台方寸山斜月三星洞”,”神界”,”拂尘”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(15,“白骨精”,”白骨夫人”,1000,”白虎岭”,”妖界”,”白骨剑”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(16,“金角大王”,”大大王”,800,”平顶山莲花洞”,”妖界”,”紫金红葫芦”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(17,“银角大王”,”二大王”,700,”平顶山莲花洞”,”妖界”,”羊脂玉净瓶”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(18,“哪吒”,”哪吒三太子”,800,”天庭”,”神界”,”风火轮”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(19,“杨戬”,”二郎神”,2000,”天庭”,”神界”,”三尖双刃刀”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(20,“太上老君”,”太上祖道”,20000,”天庭”,”神界”,”拂尘”,”西游记”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(21,“刘备”,”刘玄德”,40,” 涿郡涿县”,”蜀国”,”双股剑”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(22,“关羽”,”关云长”,35,”河东郡解良县”,”蜀国”,”青龙偃月刀”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(23,“张飞”,”张益德”,32,”涿郡”,”蜀国”,”丈八蛇矛”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(24,“诸葛亮”,”诸葛孔明”,27,”徐州琅琊阳都”,”蜀国”,””,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(25,“赵云”,”赵子龙”,29,”常山真定”,”蜀国”,”涯角枪”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(26,“黄忠”,”黄汉升”,50,”南阳”,”蜀国”,”凤嘴刀”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(27,“马超”,”马孟起”,30,”扶风茂陵”,”蜀国”,”马骑枪”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(28,“曹操”,”曹孟德”,46,”沛国谯县”,”魏国”,”倚天剑和青釭剑”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(29,“庞统”,”庞士元”,29,”襄阳”,”蜀国”,””,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(30,“夏侯惇”,”夏元让”,35,” 沛国谯县”,”魏国”,”长枪”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(31,“司马懿”,”司仲达”,29,”河内温县”,”魏国”,””,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(32,“典韦”,”古之恶来”,30,”陈留己吾”,”魏国”,”大双戟”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(33,“孙坚”,”孙文台”,40,”吴郡富春”,”吴国”,”长剑”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(34,“孙策”,”孙伯符”,20,”吴郡富春”,”吴国”,”长剑”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(35,“孙权”,”孙仲谋”,13,”吴郡富春”,”吴国”,”双剑”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(36,“黄盖”,”黄公覆”,29,”零陵郡泉陵”,”吴国”,”大双戟”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(37,“周瑜”,”周公瑾”,28,”庐江郡舒”,”吴国”,””,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(38,“吕蒙”,”吕子明”,32,”汝南富陂”,”吴国”,”长枪”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(39,“吕布”,”吕奉先”,33,”五原九元”,”魏国”,”方天画戟”,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(40,“徐庶”,”徐元直”,37,”颍川郡长社”,”蜀国”,””,”三国演义”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(41,“光头强”,”强哥”,32,”狗熊零”,”伐木组”,”电锯”,”熊出没”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(42,“凯”,”曙光凯”,37,”四川”,”长城守卫”,”曙光刀”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(43,“花木兰”,”巾帼英雄”,29,”四川”,”长城守卫”,”木兰刀”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(44,“苏烈”,”苏大强”,37,”四川”,”长城守卫”,”大柱”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(45,“百里守约”,”狙击手”,26,”陕西”,”长城守卫”,”狙击枪”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(46,“百里玄策”,”暗影勾手”,28,”陕西”,”长城守卫”,”暗影镰刀”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(47,“李白”,”青年居士”,28,”四川”,”长安”,”大河之剑”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(48,“盾山”,”铁石头”,56,”四川”,”长城守卫”,”坚固之盾”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(49,“李信”,”光暗信”,35,”湖南”,”长城守卫”,”长剑”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(50,“沈梦溪”,”炸弹人”,22,”湖北”,”长城守卫”,”投掷炸弹”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(51,“伽罗”,”长空射手”,26,”重庆”,”长城守卫”,”长空之弓”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(52,“兰陵王”,”暗影刺客”,37,”新疆”,”长城守卫”,”匕首”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(53,“明世隐”,”万能医疗箱”,35,”新疆”,”尧天”,”明镜”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(54,“裴擒虎”,”猛虎勇士”,29,””,”尧天”,”虎爪”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(55,“公孙离”,”盛世舞姬”,26,”新疆”,”尧天”,”雨伞”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(56,“杨玉环”,”杨贵妃”,35,”新疆”,”尧天”,”琵琶”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(57,“弈星”,”天元之弈”,28,”陕西”,”尧天”,”棋盘”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(58,“盘古”,”元始天王”,100000000,”四川”,”日之塔”,”开天斧”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(59,“女娲”,”创世女神”,100000000,”新疆”,”日之塔”,”混沌无极刀”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(60,“后裔”,”逐日者”,80000000,”新疆”,”日之塔”,”逐日之弓”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(61,“太乙真人”,”清微教主”,6000000,”陕西”,”日之塔”,”炼金瓶”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(62,“姜子牙”,”姜太公”,75,”陕西”,”日之塔”,”封神榜”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(63,“曜”,”东方曜”,2000,”北京”,”稷下星之队”,”光剑”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(64,“李元芳”,”水生”,30,”北京”,”长安”,”飞轮”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(65,“狄仁杰”,”断案大师”,46,”北京”,”长安”,”亢龙锏”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(66,“上官婉儿”,”上官昭容”,30,”陕西”,”长安”,”毛笔”,”王者荣耀”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(67,“宋江”,”及时雨”,42,”陕西”,”梁山好汉”,”长剑”,”水浒传”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(68,“晁盖”,”托塔天王”,40,”陕西”,”梁山好汉”,”长剑”,”水浒传”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(69,“卢俊义”,”玉麒麟”,38,”陕西”,”梁山好汉”,”长枪”,”水浒传”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(70,“林冲”,”豹子头”,40,”陕西”,”梁山好汉”,”长枪”,”水浒传”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(71,“李逵”,”黑旋风”,40,”四川”,”梁山好汉”,”双斧”,”水浒传”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(72,“鲁智深”,”花和尚”,36,”四川”,”梁山好汉”,”禅杖”,”水浒传”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(73,“武松”,”行者”,38,”重庆”,”梁山好汉”,”双刀”,”水浒传”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(74,“杨志”,”青面兽”,35,”重庆”,”梁山好汉”,”长枪”,”水浒传”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(75,“吴用”,”智多星”,39,”重庆”,”梁山好汉”,”长剑”,”水浒传”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(76,“土行孙”,”遁地者”,30,”陕西”,”伐纣队伍”,”捆仙绳”,”封神榜”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(77,“姬发”,”周武王”,21,”重庆”,”伐纣队伍”,”长剑”,”封神榜”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(78,“邓婵玉”,”六合星君”,26,”陕西”,”伐纣队伍”,”双刀”,”封神榜”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(79,“闻仲”,”闻太师”,55,”湖北”,”纣王队伍”,”雌雄蛟龙双鞭”,”封神榜”);
insert into t_hero(id, Name, Nickname, Age, Address,job,weapon,bloc) values(80,“纣王”,”子受”,40,”陕西”,”纣王队伍”,”长剑”,”水浒传”);


 四.字段增加及删除

增加字段
Alter table t_hero add gender enum('男', '女') default '女';
Alter table t_hero add classes varchar(100);

删除字段
Alter table t_hero drop classes;

Mysql——创建数据库,对表的创建及字段定义、数据录入、字段增加及删除、重命名表。_第1张图片

Mysql——创建数据库,对表的创建及字段定义、数据录入、字段增加及删除、重命名表。_第2张图片

五.重命名表 

alter table t_hero rename hero;

Mysql——创建数据库,对表的创建及字段定义、数据录入、字段增加及删除、重命名表。_第3张图片

你可能感兴趣的:(数据库,数据库,mysql,oracle)