10.4管理表单及数据

1.向数据表插入数据,并查看数据

MariaDB [dsrw]> INSERT INTO mybook(name,price,pages) VALUES('dsrw','99', '1000') ;
MariaDB [dsrw]> SELECT * from mybook;
+------+-------+-------+
| name | price | pages |
+------+-------+-------+
| dsrw |    99 |  1000 |
+------+-------+-------+
1 row in set (0.000 sec)

2.更新数据

1)更新价格
MariaDB [dsrw]> UPDATE mybook SET price=49;
Query OK, 1 row affected (0.001 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [dsrw]> SELECT * from mybook;
+------+-------+-------+
| name | price | pages |
+------+-------+-------+
| dsrw |    49 |  1000 |
+------+-------+-------+
1 row in set (0.000 sec)
2)带条件更新
MariaDB [dsrw]> INSERT INTO mybook(name,price,pages) VALUES('dsrw.com','55', '200');
Query OK, 1 row affected (0.001 sec)

MariaDB [dsrw]> INSERT INTO mybook(name,price,pages) VALUES('dsrw.cn','68', '100');
Query OK, 1 row affected (0.001 sec)

MariaDB [dsrw]> UPDATE mybook SET price=60 where name='dsrw.com';
Query OK, 1 row affected (0.001 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [dsrw]> SELECT * from mybook;
+----------+-------+-------+
| name     | price | pages |
+----------+-------+-------+
| dsrw     |    49 |  1000 |
| dsrw.com |    60 |   200 |
| dsrw.cn  |    68 |   100 |
+----------+-------+-------+
3 rows in set (0.000 sec)

3.删除数据

MariaDB [dsrw]> DELETE FROM mybook  where name='dsrw.cn';
Query OK, 1 row affected (0.002 sec)

MariaDB [dsrw]> SELECT * from mybook;
+----------+-------+-------+
| name     | price | pages |
+----------+-------+-------+
| dsrw     |    49 |  1000 |
| dsrw.com |    60 |   200 |
+----------+-------+-------+
2 rows in set (0.000 sec)
© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称

    请登录后查看评论内容