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
请登录后查看评论内容