美文网首页
小练习(二)

小练习(二)

作者: knot98 | 来源:发表于2018-09-13 21:06 被阅读0次
题一:

mysql> create database day0913_homework_02;
Query OK, 1 row affected (0.00 sec)

mysql> use day0913_homework_02;
Database changed
mysql> create table shopping_info(
    -> id int primary key auto_increment,
    -> people char(5) not null,
    -> product char(5) not null,
    -> count int not null
    -> );
Query OK, 0 rows affected (0.02 sec)

mysql> insert into shopping_info values
    -> (null,'A','甲',2),
    -> (null,'B','乙',4),
    -> (null,'C','丙',1);
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select people from shopping_info where count >=2;
+--------+
| people |
+--------+
| A      |
| B      |
+--------+
2 rows in set (0.00 sec)

mysql> select product from shopping_info where count =2;
+---------+
| product |
+---------+
| 甲      |
+---------+
1 row in set (0.00 sec)

mysql> select people from shopping_info where count =4;
+--------+
| people |
+--------+
| B      |
+--------+
1 row in set (0.00 sec)

mysql> update shopping_info set count = 10 where people ='A';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select *from shopping_info;
+----+--------+---------+-------+
| id | people | product | count |
+----+--------+---------+-------+
|  1 | A      | 甲      |    10 |
|  2 | B      | 乙      |     4 |
|  3 | C      | 丙      |     1 |
+----+--------+---------+-------+
3 rows in set (0.00 sec)

mysql> delete from shopping_info where count =1;
Query OK, 1 row affected (0.01 sec)

mysql> select *from shopping_info;
+----+--------+---------+-------+
| id | people | product | count |
+----+--------+---------+-------+
|  1 | A      | 甲      |    10 |
|  2 | B      | 乙      |     4 |
+----+--------+---------+-------+
2 rows in set (0.00 sec)

--------------------------------------------------------------------------

题二

mysql> create table student(
    -> id int primary key auto_increment,
    -> name char(5) not null,
    -> course char(5) default '语文',
    -> score int not null
    -> );
Query OK, 0 rows affected (0.05 sec)

mysql> insert into student(name,score) values
    -> ('张三',81),
    -> ('李四',90),
    -> ('王五',49);
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select *from student;
+----+--------+--------+-------+
| id | name   | course | score |
+----+--------+--------+-------+
|  1 | 张三   | 语文   |    81 |
|  2 | 李四   | 语文   |    90 |
|  3 | 王五   | 语文   |    49 |
+----+--------+--------+-------+
3 rows in set (0.00 sec)

mysql> select name from student where score >=60;
+--------+
| name   |
+--------+
| 张三   |
| 李四   |
+--------+
2 rows in set (0.00 sec)

mysql> select name from student where score >=90;
+--------+
| name   |
+--------+
| 李四   |
+--------+
1 row in set (0.00 sec)

mysql> select name,course from student where score =49;
+--------+--------+
| name   | course |
+--------+--------+
| 王五   | 语文   |
+--------+--------+
1 row in set (0.00 sec)

mysql> update student set score = 60 where name ='王五';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> delete from student where name = '李四';
Query OK, 1 row affected (0.01 sec)

mysql> select *from student;
+----+--------+--------+-------+
| id | name   | course | score |
+----+--------+--------+-------+
|  1 | 张三   | 语文   |    81 |
|  3 | 王五   | 语文   |    60 |
+----+--------+--------+-------+
2 rows in set (0.00 sec)

---------------------------------------------------------------------------------

题三

mysql> create table student_2(
    -> id int primary key auto_increment,
    -> name char(5) not null,
    -> password int not null,
    -> age int not null,
    -> reg_time timestamp not null,
    -> weight float(60,2) not null
    -> );
Query OK, 0 rows affected (0.02 sec)

mysql> insert into student_2 values
    -> (null,'hgq',123,20,now(),50),
    -> (null,'zkq',123,20,now(),40);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select *from student_2;
+----+------+----------+-----+---------------------+--------+
| id | name | password | age | reg_time            | weight |
+----+------+----------+-----+---------------------+--------+
|  1 | hgq  |      123 |  20 | 2018-09-13 19:38:10 |  50.00 |
|  2 | zkq  |      123 |  20 | 2018-09-13 19:38:10 |  40.00 |
+----+------+----------+-----+---------------------+--------+
2 rows in set (0.00 sec)

相关文章

  • 二项分布问题

    二项分布问题 小练习1 解析 小练习2 解析 小练习3 解析 小练习4 解析 小练习5 解析 小练习6 解析 小练...

  • 二项展开式的通项问题

    二项展开式的通项问题 二项展开式的通项 通项的应用 小练习1 解析 小练习2 解析 小练习3 解析 小练习4 解析...

  • 小练习(二)

  • 小练习(二)

    每个人小时候,都有个小兔子乖乖吧。你那么喜欢它,给它吃白菜和胡萝卜,抱着它,抚摸它。 你的手掠过长发,凌乱了眼眸里...

  • 小像练习(二)

  • 求离散型随机变量的分布列及数字特征问题

    小练习1 解析 小练习2 小练习3 解析 小练习4 解析 小练习5 解析 小练习6 解析 小练习7 解析 小练习8...

  • 二级腿的柔韧练习

    腿的练习。二级A 一.热身。(围圆走,手位练习) 二.活动组合:卡路里。 腿的柔韧练习。 三.小翅膀组合 1.腿的...

  • 2018-12-21

    腿的练习。二级A 一.热身。(围圆走,手位练习) 二.活动组合:卡路里。 腿的柔韧练习。 三.小翅膀组合 1.腿的...

  • 指对幂函比大小问题

    概述 步骤 拓展 小练习1 解析 小练习2 解析 小练习3 解析 小练习4 解析 小练习5 解析 小练习6 解析 ...

  • 2019-04-16 数组(splice)、数组去重、练习-省市

    数组 数组去重 二维数组 练习-省市联动(数组方法) 练习-省市联动(json方法) DOM(节点) 父节点小练习...

网友评论

      本文标题:小练习(二)

      本文链接:https://www.haomeiwen.com/subject/tgvggftx.html