英雄表的创建 -- 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)
相关推荐
一条闲鱼_mytube26 分钟前
深入理解 Pinecone 向量数据库:从云服务到索引原理,一篇讲透
数据库
许彰午37 分钟前
政务低代码平台实战⑤:双输出模式——存DB与导出JSP的完整链路
数据库·低代码·政务
南京码讯光电技术有限公司1 小时前
What Does Ex tb IIIC T80°C Db Mean?
服务器·网络·数据库
2501_937860942 小时前
MySQL CRUD 增删改查
数据库·mysql
做萤石二次开发的哈哈2 小时前
萤石蓝海AIoT一站式工作台计费说明
网络·数据库·萤石开放平台·蓝海aiot一站式工作台
竹枝溪2 小时前
MySQL数据库零基础入门
数据库·sql·mysql·navicat·ddl·dml·dql
龙仔7252 小时前
人大金仓Kingbase V8 自动全量备份部署完整笔记
数据库·笔记·备份·人大金仓
王志来137944730082 小时前
从选型到交付,工控服务器机箱一站式采购平台匀天如何实现服务闭环?
数据库
ShuiShenHuoLe2 小时前
HmarkX(码笺)的本地数据库模块重构实战
数据库·oracle·重构
Databend2 小时前
从 Kafka 到 Databend Cloud:万亿级 Agent Trace 接入链路的工程实践
大数据·数据库·agent