1. 安装MySQL并且联动NAVICAT
2. 创建数据库 db_clasess
命令语:
create DATABASE db_classes;
2.1 create前,无db_claseses数据库
2.2 create后,出现db_claseses数据库
3. 创建表 db_hero
命令语:
Create table db_hero(
Id int primary key auto_increment,
Name varchar(50) not null unique,
nickname varchar(50) not null,
Age int default 0,
Gender varchar(10) check(gender in("男","女")),
Address varchar(150) not null,
weapon varchar(30) not null,
word varchar(30) not null,
types varchar(30) not null
);
3.1 create table的SQL执行成功
3.2 在db_classes数据库中,出现db_hero table
3.3 通过设计表,看到table按照SQL语句执行成功,id为主键,并且自动递增
4. 写insert语句
命令语:
INSERT INTO db_hero (name,nickname,age,gender,address,weapon,word,types)
values ("孙悟空","齐天大圣",888,"男","花果山","金箍棒","西游记","妖族"),
("猪八戒","天蓬元帅",777,"男","天庭","九尺钉钯","西游记","妖族");
4.1 insert语句输入成功
4.2 查询表格,输入准确,并且id号码依次递增