1.创建一个英雄表(hero)
主键
name
nickname
address
groups
email
telphone
1.1创建一个数据库test
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sakila |
| sys |
| world |
+--------------------+
6 rows in set (0.00 sec)
mysql> create database db_han;
Query OK, 1 row affected (0.00 sec)
mysql> use db_han;
Database changed
1.2创建一个英雄hero表
mysql> create table if not exists t_hero(
-> id int primary key auto_increment,
-> name varchar(50) not null unique,
-> nickname varchar (100) unique,
-> address varchar(100),
-> `groups` varchar(100),
-> email varchar(100),
-> telphone int
-> );
Query OK, 0 rows affected (0.05 sec)
1.3描述这张表
mysql> desc t_hero;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| name | varchar(50) | NO | UNI | NULL | |
| nickname | varchar(100) | YES | UNI | NULL | |
| address | varchar(100) | YES | | NULL | |
| groups | varchar(100) | YES | | NULL | |
| email | varchar(100) | YES | | NULL | |
| telphone | int | YES | | NULL | |
+----------+--------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)
1.4插入字段
insert into t_hero values(null, "孙悟空", "齐天大圣", "花果山水帘洞","西游记", "[email protected]",13571894);
insert into t_hero values(null, "猪八戒", "天蓬元帅", "高老庄","西游记", "[email protected]",155171894);
insert into t_hero values(null, "沙悟净", "卷帘大将", "流沙河","西游记", "[email protected]",13191894);
insert into t_hero values(null, "刘备", "玄德", "河北","三国演义", "[email protected]",135718569);
insert into t_hero values(null, "宋江", "公明", "山东","水浒传", "[email protected]",1357188894);
insert into t_hero values(null, "潘金莲", "金莲", "阳谷县","水浒传", "[email protected]",1352371894);
insert into t_hero values(null, "鲁智深", "花和尚", "甘肃平凉","水浒传", "[email protected]",1357641894);
insert into t_hero values(null, "贾宝玉", "花主", "荣府","红楼梦", "[email protected]",177559894);
insert into t_hero values(null, "林黛玉", "潇湘妃子", "姑苏","hlm", "[email protected]",133571894);
insert into t_hero values(null, "王熙凤", "凤辣子", "贾府","红楼梦", "[email protected]",134571894);
insert into t_hero values(null, "曹操", "孟德", "安徽毫州","三国演义", "[email protected]",135717894);
insert into t_hero values(null, "周瑜", "公瑾", "庐江舒县","三国演义", "[email protected]",1355671894);
insert into t_hero values(null, "诸葛亮", "卧龙", "岐山","三国演义", "[email protected]",143571894);
1.5查询hero表
安装好之后,在桌面右键点击我的电脑(有些是此电脑),然后点击属性,进入系统信息设置,接着点击高级,进入环境变量界面,进入环境变量界面,编辑path变量,输入mysql安装路径下的bin目录,这里的是mysql默认安装目录