2017-08-15 18:03:17

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| animal_protected   |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set

mysql> use animal_protected;
Database changed
mysql> show tables;
+----------------------------+
| Tables_in_animal_protected |
+----------------------------+
| user_info                  |
+----------------------------+
1 row in set

mysql> desc user_info;
+---------+--------------+------+-----+---------+-------+
| Field   | Type         | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| ID      | smallint(4)  | NO   | PRI | NULL    |       |
| name    | char(4)      | NO   |     | NULL    |       |
| kind    | char(2)      | NO   |     | NULL    |       |
| number  | mediumint(6) | YES  |     | NULL    |       |
| address | varchar(8)   | NO   |     | NULL    |       |
+---------+--------------+------+-----+---------+-------+
5 rows in set

mysql> select*from user_info;
+------+--------+------+--------+----------+
| ID   | name   | kind | number | address  |
+------+--------+------+--------+----------+
| 1801 | 美洲豹 | 猫科 |  16663 | 墨西哥   |
| 1802 | 非洲象 | 象科 | 357281 | 津巴布韦 |
| 1803 | 亚洲象 | 象科 |  52359 | 印度     |
| 1804 | 金钱豹 | 猫科 |     78 | 孟加拉   |
+------+--------+------+--------+----------+
4 rows in set

mysql> select name from user_info;
+--------+
| name   |
+--------+
| 美洲豹 |
| 非洲象 |
| 亚洲象 |
| 金钱豹 |
+--------+
4 rows in set

mysql> insert into user_info(ID,name,kind,number,address)values(1805,'白熊','熊科',21006,'北极
');
Query OK, 1 row affected
1062 - Duplicate entry '1805' for key 'PRIMARY'
    -> ;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Query OK, 1 row affected' at line 1
mysql> insert into user_info(ID,name,kind,number,address)values(1806,'美洲豹','猫科',130508,'墨西哥
');
Query OK, 1 row affected
1062 - Duplicate entry '1806' for key 'PRIMARY'
    -> ;
    -> ;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Query OK, 1 row affected

;' at line 1
mysql> insert into user_info(ID,name,kind,number,address)values(1807,'棕熊','熊科',90086,'阿富汗
');
Query OK, 1 row affected
1062 - Duplicate entry '1807' for key 'PRIMARY'
    -> ;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Query OK, 1 row affected' at line 1
mysql> insert into user_info(ID,name,kind,number,address)values(1808,'华南虎','猫科',0,'中国
');
Query OK, 1 row affected
1062 - Duplicate entry '1808' for key 'PRIMARY'
    -> ;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Query OK, 1 row affected' at line 1
mysql> insert into user_info(ID,name,kind,number,address)values(1809,'熊猫','熊科',1668,'中国
');
Query OK, 1 row affected
1062 - Duplicate entry '1809' for key 'PRIMARY'
    -> ;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Query OK, 1 row affected' at line 1
mysql> insert into user_info(ID,name,kind,number,address)values(1810,'孟加拉虎','猫科',5102,'孟加拉
');
Query OK, 1 row affected
1062 - Duplicate entry '1810' for key 'PRIMARY'
    -> ;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Query OK, 1 row affected' at line 1
mysql> insert into user_info(ID,name,kind,number,address)values(1811,'东北虎,'猫科',21,'中国
');
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '猫科',21,'中国');

insert into user_info(ID,name,kind,number,address)valu' at line 1
mysql>
mysql> select*from user_info;
+------+----------+------+--------+----------+
| ID   | name     | kind | number | address  |
+------+----------+------+--------+----------+
| 1801 | 美洲豹   | 猫科 |  16663 | 墨西哥   |
| 1802 | 非洲象   | 象科 | 357281 | 津巴布韦 |
| 1803 | 亚洲象   | 象科 |  52359 | 印度     |
| 1804 | 金钱豹   | 猫科 |     78 | 孟加拉   |
| 1805 | 白熊     | 熊科 |  21006 | 北极     |
| 1806 | 美洲豹   | 猫科 | 130508 | 墨西哥   |
| 1807 | 棕熊     | 熊科 |  90086 | 阿富汗   |
| 1808 | 华南虎   | 猫科 |      0 | 中国     |
| 1809 | 熊猫     | 熊科 |   1668 | 中国     |
| 1810 | 孟加拉虎 | 猫科 |   5102 | 孟加拉   |
+------+----------+------+--------+----------+
10 rows in set

mysql> insert into user_info(ID,name,kind,number,address)values(1811,'东北虎','猫科',21,'中国');
Query OK, 1 row affected
mysql> select*from user_info;
+------+----------+------+--------+----------+
| ID   | name     | kind | number | address  |
+------+----------+------+--------+----------+
| 1801 | 美洲豹   | 猫科 |  16663 | 墨西哥   |
| 1802 | 非洲象   | 象科 | 357281 | 津巴布韦 |
| 1803 | 亚洲象   | 象科 |  52359 | 印度     |
| 1804 | 金钱豹   | 猫科 |     78 | 孟加拉   |
| 1805 | 白熊     | 熊科 |  21006 | 北极     |
| 1806 | 美洲豹   | 猫科 | 130508 | 墨西哥   |
| 1807 | 棕熊     | 熊科 |  90086 | 阿富汗   |
| 1808 | 华南虎   | 猫科 |      0 | 中国     |
| 1809 | 熊猫     | 熊科 |   1668 | 中国     |
| 1810 | 孟加拉虎 | 猫科 |   5102 | 孟加拉   |
| 1811 | 东北虎   | 猫科 |     21 | 中国     |
+------+----------+------+--------+----------+
11 rows in set

mysql> select *from user_info where kind="猫科";
+------+----------+------+--------+---------+
| ID   | name     | kind | number | address |
+------+----------+------+--------+---------+
| 1801 | 美洲豹   | 猫科 |  16663 | 墨西哥  |
| 1804 | 金钱豹   | 猫科 |     78 | 孟加拉  |
| 1806 | 美洲豹   | 猫科 | 130508 | 墨西哥  |
| 1808 | 华南虎   | 猫科 |      0 | 中国    |
| 1810 | 孟加拉虎 | 猫科 |   5102 | 孟加拉  |
| 1811 | 东北虎   | 猫科 |     21 | 中国    |
+------+----------+------+--------+---------+
6 rows in set

mysql> select *from user_info where number<2000;
+------+--------+------+--------+---------+
| ID   | name   | kind | number | address |
+------+--------+------+--------+---------+
| 1804 | 金钱豹 | 猫科 |     78 | 孟加拉  |
| 1808 | 华南虎 | 猫科 |      0 | 中国    |
| 1809 | 熊猫   | 熊科 |   1668 | 中国    |
| 1811 | 东北虎 | 猫科 |     21 | 中国    |
+------+--------+------+--------+---------+
4 rows in set

mysql> updata user_info set address="美国" where ID=1806;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'updata user_info set address="美国" where ID=1806' at line 1
mysql> select *from user_info;
+------+----------+------+--------+----------+
| ID   | name     | kind | number | address  |
+------+----------+------+--------+----------+
| 1801 | 美洲豹   | 猫科 |  16663 | 墨西哥   |
| 1802 | 非洲象   | 象科 | 357281 | 津巴布韦 |
| 1803 | 亚洲象   | 象科 |  52359 | 印度     |
| 1804 | 金钱豹   | 猫科 |     78 | 孟加拉   |
| 1805 | 白熊     | 熊科 |  21006 | 北极     |
| 1806 | 美洲豹   | 猫科 | 130508 | 墨西哥   |
| 1807 | 棕熊     | 熊科 |  90086 | 阿富汗   |
| 1808 | 华南虎   | 猫科 |      0 | 中国     |
| 1809 | 熊猫     | 熊科 |   1668 | 中国     |
| 1810 | 孟加拉虎 | 猫科 |   5102 | 孟加拉   |
| 1811 | 东北虎   | 猫科 |     21 | 中国     |
+------+----------+------+--------+----------+
11 rows in set

mysql> update user_info set name='美洲狮' address='美国' where ID=1806;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'address='美国' where ID=1806' at line 1
mysql> update user_info set name="美洲狮" where ID=1806;
Query OK, 1 row affected
Rows matched: 1  Changed: 1  Warnings: 0
mysql> update user_info set address="美国" where ID=1806;
Query OK, 1 row affected
Rows matched: 1  Changed: 1  Warnings: 0
mysql> select*from user_info;
+------+----------+------+--------+----------+
| ID   | name     | kind | number | address  |
+------+----------+------+--------+----------+
| 1801 | 美洲豹   | 猫科 |  16663 | 墨西哥   |
| 1802 | 非洲象   | 象科 | 357281 | 津巴布韦 |
| 1803 | 亚洲象   | 象科 |  52359 | 印度     |
| 1804 | 金钱豹   | 猫科 |     78 | 孟加拉   |
| 1805 | 白熊     | 熊科 |  21006 | 北极     |
| 1806 | 美洲狮   | 猫科 | 130508 | 美国     |
| 1807 | 棕熊     | 熊科 |  90086 | 阿富汗   |
| 1808 | 华南虎   | 猫科 |      0 | 中国     |
| 1809 | 熊猫     | 熊科 |   1668 | 中国     |
| 1810 | 孟加拉虎 | 猫科 |   5102 | 孟加拉   |
| 1811 | 东北虎   | 猫科 |     21 | 中国     |
+------+----------+------+--------+----------+
11 rows in set

mysql> delect from user_info where number>100000;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delect from user_info where number>100000' at line 1
mysql> delete from user_info where number>100000;
Query OK, 2 rows affected
mysql> select*from user_info;
+------+----------+------+--------+---------+
| ID   | name     | kind | number | address |
+------+----------+------+--------+---------+
| 1801 | 美洲豹   | 猫科 |  16663 | 墨西哥  |
| 1803 | 亚洲象   | 象科 |  52359 | 印度    |
| 1804 | 金钱豹   | 猫科 |     78 | 孟加拉  |
| 1805 | 白熊     | 熊科 |  21006 | 北极    |
| 1807 | 棕熊     | 熊科 |  90086 | 阿富汗  |
| 1808 | 华南虎   | 猫科 |      0 | 中国    |
| 1809 | 熊猫     | 熊科 |   1668 | 中国    |
| 1810 | 孟加拉虎 | 猫科 |   5102 | 孟加拉  |
| 1811 | 东北虎   | 猫科 |     21 | 中国    |
+------+----------+------+--------+---------+
9 rows in set

mysql>

sql lesson21homework的更多相关文章

  1. 最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目

    最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目 最近一个来自重庆的客户找到走起君,客户的业务是做移动互联网支付,是微信支付收单渠道合作伙伴,数据库里存储的是支付流水和交易流水 ...

  2. SQL Server 大数据搬迁之文件组备份还原实战

    一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 解决方案(Solution) 搬迁步骤(Procedure) 搬迁脚本(SQL Codes) ...

  3. Sql Server系列:分区表操作

    1. 分区表简介 分区表在逻辑上是一个表,而物理上是多个表.从用户角度来看,分区表和普通表是一样的.使用分区表的主要目的是为改善大型表以及具有多个访问模式的表的可伸缩性和可管理性. 分区表是把数据按设 ...

  4. SQL Server中的高可用性(2)----文件与文件组

        在谈到SQL Server的高可用性之前,我们首先要谈一谈单实例的高可用性.在单实例的高可用性中,不可忽略的就是文件和文件组的高可用性.SQL Server允许在某些文件损坏或离线的情况下,允 ...

  5. EntityFramework Core Raw SQL

    前言 本节我们来讲讲EF Core中的原始查询,目前在项目中对于简单的查询直接通过EF就可以解决,但是涉及到多表查询时为了一步到位就采用了原始查询的方式进行.下面我们一起来看看. EntityFram ...

  6. 从0开始搭建SQL Server AlwaysOn 第一篇(配置域控)

    从0开始搭建SQL Server AlwaysOn 第一篇(配置域控) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://www.cnb ...

  7. 从0开始搭建SQL Server AlwaysOn 第二篇(配置故障转移集群)

    从0开始搭建SQL Server AlwaysOn 第二篇(配置故障转移集群) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://www ...

  8. 从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn)

    从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://w ...

  9. 从0开始搭建SQL Server AlwaysOn 第四篇(配置异地机房节点)

    从0开始搭建SQL Server AlwaysOn 第四篇(配置异地机房节点) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://www ...

随机推荐

  1. Android__adb 命令大全

    ADB 即 Android Debug Bridge,Android调试桥.ADB工作方式比较特殊,采用监听Socket TCP 端口的方式让IDE和Qemu通讯,默认情况下adb会daemon相关的 ...

  2. 数据库 | Redis 缓存雪崩解决方案

    Redis 雪崩 缓存层承载着大量的请求,有效保护了存储层.但是如果由于缓存大量失效或者缓存整体不能提供服务,导致大量的请求到达存储层,会使存储层负载增加,这就是缓存雪崩的场景. 解决缓存雪崩,可以从 ...

  3. @Transactional(事务讲解)和springboot 整合事务

    概述 事务在编程中分为两种:声明式事务处理和编程式事务处理 编程式事务处理:编码方式实现事务管理,常与模版类TransactionTemplate(推荐使用) 在业务代码中实现事务. 可知编程式事务每 ...

  4. go module 使用举例

    go语言中,从1.11开始,引入module,进行版本管理. 通过使用module,工程目录的位置不用必须放在GOPATH下. 本文介绍 module的使用. 下文中用的Go版本是1.13. 1. g ...

  5. LC 722. Remove Comments

    Given a C++ program, remove comments from it. The program source is an array where source[i] is the  ...

  6. input上传指定类型的文件

    1. 谷歌–上传文件夹 添加属性webkitdirectory <input type = "file" webkitdirectory> 2. 上传文件–限制类型 添 ...

  7. 魔法方法 __slots__ 方法

    场景解析 网游的用户, 大量的用户本质都是类的实例化对象, 在线人数百万级时对内存是很大的挑战, 如何减少这部分的内存 方法解析 __slots__ 方法 取消默认的类实例中的  __dict__  ...

  8. layui-简单的登录注册界面【转载】

    register.html 源代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ...

  9. 你应该知道的 MySQL 的锁

    背景 数据库的锁是在多线程高并发的情况下用来保证数据稳定性和一致性的一种机制.MySQL 根据底层存储引擎的不同,锁的支持粒度和实现机制也不同.MyISAM 只支持表锁,InnoDB 支持行锁和表锁. ...

  10. Linux命令集锦:ansible命令

    ansible 命令主要用于批量管理,来实现自动化管理.常用批量操作包括:主机分组管理.实时批量执行命令或脚本.实时批量分发文件或目录.定时同步文件等. 一.安装 ansible yum instal ...