MySQL 向表中插入、删除数据

一、向表中插入一条信息

1、查看表中的数据

mysql> SELECT * FROM user;
+----+---------+----------+
| id | account | password |
+----+---------+----------+
|  1 | mk      | 123      |
|  2 | seven   | 456      |
+----+---------+----------+
2 rows in set (0.00 sec)

2、插入数据

mysql> INSERT INTO user (account, password) VALUES('brk', '789');
Query OK, 1 row affected (0.56 sec)

3、再次查看表中的数据

mysql> SELECT * FROM user;
+----+---------+----------+
| id | account | password |
+----+---------+----------+
|  1 | mk      | 123      |
|  2 | seven   | 456      |
|  3 | brk     | 789      |
+----+---------+----------+
3 rows in set (0.00 sec)

二、从表中删除一条信息

1、查看表中的数据

mysql> SELECT * FROM user;
+----+---------+----------+
| id | account | password |
+----+---------+----------+
|  1 | mk      | 123      |
|  2 | seven   | 456      |
|  3 | brk     | 789      |
+----+---------+----------+
3 rows in set (0.00 sec)

2、删除数据

mysql> DELETE FROM user WHERE account='brk';
Query OK, 1 row affected (0.57 sec)

3、再次查看表中的数据

mysql> SELECT * FROM user;
+----+---------+----------+
| id | account | password |
+----+---------+----------+
|  1 | mk      | 123      |
|  2 | seven   | 456      |
+----+---------+----------+
2 rows in set (0.00 sec)
原文地址:https://www.cnblogs.com/Satu/p/10652242.html