MYSQL 1

发布时间:2024年01月18日

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, "孙悟空", "齐天大圣", "花果山水帘洞","西游记", "545454@qq.com",13571894); ?
insert into t_hero values(null, "猪八戒", "天蓬元帅", "高老庄","西游记", "54265454@qq.com",155171894);
insert into t_hero values(null, "沙悟净", "卷帘大将", "流沙河","西游记", "54545436@qq.com",13191894);
insert into t_hero values(null, "刘备", "玄德", "河北","三国演义", "54519454@qq.com",135718569);
insert into t_hero values(null, "宋江", "公明", "山东","水浒传", "51245454@qq.com",1357188894);
insert into t_hero values(null, "潘金莲", "金莲", "阳谷县","水浒传", "11545454@qq.com",1352371894);
insert into t_hero values(null, "鲁智深", "花和尚", "甘肃平凉","水浒传", "54513454@qq.com",1357641894);
insert into t_hero values(null, "贾宝玉", "花主", "荣府","红楼梦", "541354514@qq.com",177559894);
insert into t_hero values(null, "林黛玉", "潇湘妃子", "姑苏","hlm", "511245454@qq.com",133571894);
insert into t_hero values(null, "王熙凤", "凤辣子", "贾府","红楼梦", "54536454@qq.com",134571894);
insert into t_hero values(null, "曹操", "孟德", "安徽毫州","三国演义", "54645454@qq.com",135717894);
insert into t_hero values(null, "周瑜", "公瑾", "庐江舒县","三国演义", "12565454@qq.com",1355671894);
insert into t_hero values(null, "诸葛亮", "卧龙", "岐山","三国演义", "51845454@qq.com",143571894);

?1.5查询hero表


?2.window系统安装MySQL

2.1下载MySQL

2.2安装MySQL

2.3配置MySQL

安装好之后,在桌面右键点击我的电脑(有些是此电脑),然后点击属性,进入系统信息设置,接着点击高级,进入环境变量界面,进入环境变量界面,编辑path变量,输入mysql安装路径下的bin目录,这里的是mysql默认安装目录

文章来源:https://blog.csdn.net/weixin_61885606/article/details/135600084
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。