英雄表的创建 -- MySQL(2)

目录

题目:

解答:


题目:

英雄表(hero)

主键

name

nickname

address

groups

email

telephone

解答:

第一步:

进入数据库

复制代码
[root@localhost ~]# mysql -uroot -pAdmin123!
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql8.0 [(none)]>

第二步:

创建数据库并使用

复制代码
mysql8.0 [(none)]>create database zuoye;
Query OK, 1 row affected (0.00 sec)
 
mysql8.0 [(none)]>use zuoye;
Database changed
mysql8.0 [zuoye]>

第三步:

创建表hero

复制代码
mysql8.0 [zuoye]>create table hero( 
    -> id int auto_increment primary key, 
    -> name varchar(255) not null, 
    -> nickname varchar(255), 
    -> address varchar(255), 
    -> group_ varchar(255), 
    -> email varchar(255), 
    -> telephone int 
    -> );
Query OK, 0 rows affected (0.01 sec)

第四步:

向表中添加数据

复制代码
mysql8.0 [zuoye]>insert into hero values
    -> ('宋江','及时雨','宋家村','水浒传','5968423@qq.com',12345678932),
    -> ('孙悟空','齐天大圣','花果山','西游记','9512368@qq.com',96325874156),
    -> ('吴用','智多星','吴家庄','水浒传','85215694@qq.com',75321469854), 
    -> ('诸葛亮','孔明','蜀国','三国演义','3854236@qq.com',85214796354);
Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0

第五步:

查看数据

复制代码
mysql8.0 [zuoye]>select * from hero;
+----+-----------+--------------+-----------+--------------+-----------------+------------+
| id | name      | nickname     | address   | group_       | email           | telephone  |
+----+-----------+--------------+-----------+--------------+-----------------+------------+
|  1 | 宋江      |  及时雨       | 宋家村    | 水浒传        | 5968423@qq.com  |12345678932 |
|  2 | 孙悟空    | 齐天大圣      | 花果山     | 西游记       | 9512368@qq.com  | 96325874156|
|  3 | 吴用      | 智多星        | 吴家庄     | 水浒传       | 85215694@qq.com | 75321469854|
|  4 | 诸葛亮    | 孔明          | 蜀国      | 三国演义      | 3854236@qq.com  |85214796354 |
+----+-----------+--------------+-----------+--------------+-----------------+------------+
4 rows in set (0.00 sec)
相关推荐
lingggggaaaa3 小时前
小迪安全v2023学习笔记(一百三十四讲)—— Windows权限提升篇&数据库篇&MySQL&MSSQL&Oracle&自动化项目
java·数据库·windows·笔记·学习·安全·网络安全
小光学长3 小时前
基于Vue的保护动物信息管理系统r7zl6b88 (程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
前端·数据库·vue.js
一匹电信狗3 小时前
【MySQL】数据库的相关操作
linux·运维·服务器·数据库·mysql·ubuntu·小程序
TDengine (老段)5 小时前
连接 TDengine 遇到报错 “failed to connect to server, reason: Connection refused” 怎么办?
大数据·数据库·物联网·时序数据库·iot·tdengine·涛思数据
李慕婉学姐5 小时前
Springboot黄河文化科普网站5q37v(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
数据库·spring boot·后端
Cabbage_acmer6 小时前
MySQL期中考试突击!
数据库·mysql
Lu Yao_6 小时前
Redis 缓存
数据库·redis·缓存
小桥流水人家哇7 小时前
性能测试单场景测试时,是设置并发读多个文件,还是设置不同的用户读不同的文件?
数据库·性能测试技巧
表示这么伤脑筋的题我不会7 小时前
Oracle 21C 部署ogg踩过的坑
数据库·oracle
你不是我我7 小时前
【Java 开发日记】MySQL 与 Redis 如何保证双写一致性?
数据库·redis·缓存