MYSQL---创建表

一、题目

1、创建一个英雄表(hero)
主键
name
nickname
address
groups
email
telphone

二、步骤

(1)第一步:进入数据库

[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)]>

(2)第二步:创建数据库并使用

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

(3)第三步:创建英雄表(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)

(4)第四步:向表中添加数据

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

(5)第五步:查看表中数据

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)

  • 11
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值