英雄表的创建 -- 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)
相关推荐
不断高歌4 分钟前
MySQL基础随堂笔记3
数据库·mysql
筵陌4 分钟前
MySQL表的增删查改(上)
数据库·mysql
paperxie_xiexuo36 分钟前
学术与职场演示文稿的结构化生成机制探析:基于 PaperXie AI PPT 功能的流程解构与适用性研究
大数据·数据库·人工智能·powerpoint
筵陌1 小时前
MySQL表的约束
数据库·mysql
UCoding1 小时前
我们来学mysql -- ReadView工作原理
数据库·mysql·readview工作原理
angushine1 小时前
解决MySQL慢日志输出问题
android·数据库·mysql
合作小小程序员小小店1 小时前
网页开发,在线%旧版本旅游管理%系统,基于eclipse,html,css,jquery,servlet,jsp,mysql数据库
java·数据库·servlet·eclipse·jdk·旅游·jsp
q***46522 小时前
Spring Boot 实战:轻松实现文件上传与下载功能
java·数据库·spring boot
腾讯云数据库2 小时前
「腾讯云 NoSQL 技术」之 Redis 篇|揭晓腾讯云Redis水平扩缩容极致流畅背后的技术玄机
数据库
SelectDB3 小时前
压缩率提升 48%,详解 Apache Doris 存储压缩优化之道|Deep Dive
数据库·开源·github