数据,数据,命根就在数据 ! 操作数据库时,一定要谨慎小心。师万物 的代码看看就好,要有自己的判断。遇到抉择,要不耻上下问。
stu@Ubuntu:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 47
Server version: 8.0.12 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use db_chinese_medicine;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from t_fruit;
+----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+
| id | name | count | price | is_sales | note | gmt_create | gmt_modified |
+----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+
| 1 | 甜瓜 | 10 | 3.210 | 1 | 无 | 2018-10-27 19:42:56 | 2018-10-27 19:42:56 |
| 2 | 乌梅 | 20 | 5.430 | 1 | 无 | 2018-10-27 19:46:21 | 2018-10-27 19:46:21 |
| 3 | 樱桃 | 30 | 6.540 | 1 | 无 | 2018-10-27 19:46:48 | 2018-10-27 19:46:48 |
| 4 | 甘蔗 | 50 | 7.650 | 0 | 无 | 2018-10-27 19:51:13 | 2018-10-27 19:51:13 |
| 5 | 菠萝蜜 | 50 | 8.760 | 1 | 菠萝蜜和菠萝是什么关系? | 2018-10-27 19:55:44 | 2018-10-27 19:55:44 |
| 6 | 无花果 | 100 | 8.760 | 1 | 无 | 2018-10-27 19:57:48 | 2018-10-27 19:57:48 |
| 7 | 山葡萄 | 200 | 5.550 | 1 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 |
| 8 | 无漏子 | 5 | 3.320 | 0 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 |
| 9 | 五敛子 | 12 | 6.010 | 0 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 |
| 10 | 藕 | 80 | 10.200 | 0 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 |
| 11 | 栗 | 5 | 3.320 | 0 | NULL | 2018-10-27 20:24:01 | 2018-10-27 20:24:01 |
| 12 | 龙眼 | 49 | 6.540 | 0 | NULL | 2018-10-27 20:24:01 | 2018-10-27 20:24:01 |
| 13 | 楂子 | 0 | 8.100 | 0 | NULL | 2018-10-27 20:24:01 | 2018-10-27 20:24:01 |
+----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+
13 rows in set (0.00 sec)
mysql> select * from t_fruit where count<>5;
+----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+
| id | name | count | price | is_sales | note | gmt_create | gmt_modified |
+----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+
| 1 | 甜瓜 | 10 | 3.210 | 1 | 无 | 2018-10-27 19:42:56 | 2018-10-27 19:42:56 |
| 2 | 乌梅 | 20 | 5.430 | 1 | 无 | 2018-10-27 19:46:21 | 2018-10-27 19:46:21 |
| 3 | 樱桃 | 30 | 6.540 | 1 | 无 | 2018-10-27 19:46:48 | 2018-10-27 19:46:48 |
| 4 | 甘蔗 | 50 | 7.650 | 0 | 无 | 2018-10-27 19:51:13 | 2018-10-27 19:51:13 |
| 5 | 菠萝蜜 | 50 | 8.760 | 1 | 菠萝蜜和菠萝是什么关系? | 2018-10-27 19:55:44 | 2018-10-27 19:55:44 |
| 6 | 无花果 | 100 | 8.760 | 1 | 无 | 2018-10-27 19:57:48 | 2018-10-27 19:57:48 |
| 7 | 山葡萄 | 200 | 5.550 | 1 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 |
| 9 | 五敛子 | 12 | 6.010 | 0 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 |
| 10 | 藕 | 80 | 10.200 | 0 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 |
| 12 | 龙眼 | 49 | 6.540 | 0 | NULL | 2018-10-27 20:24:01 | 2018-10-27 20:24:01 |
| 13 | 楂子 | 0 | 8.100 | 0 | NULL | 2018-10-27 20:24:01 | 2018-10-27 20:24:01 |
+----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+
11 rows in set (0.00 sec)
mysql> select * from t_fruit where count != 5;
+----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+
| id | name | count | price | is_sales | note | gmt_create | gmt_modified |
+----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+
| 1 | 甜瓜 | 10 | 3.210 | 1 | 无 | 2018-10-27 19:42:56 | 2018-10-27 19:42:56 |
| 2 | 乌梅 | 20 | 5.430 | 1 | 无 | 2018-10-27 19:46:21 | 2018-10-27 19:46:21 |
| 3 | 樱桃 | 30 | 6.540 | 1 | 无 | 2018-10-27 19:46:48 | 2018-10-27 19:46:48 |
| 4 | 甘蔗 | 50 | 7.650 | 0 | 无 | 2018-10-27 19:51:13 | 2018-10-27 19:51:13 |
| 5 | 菠萝蜜 | 50 | 8.760 | 1 | 菠萝蜜和菠萝是什么关系? | 2018-10-27 19:55:44 | 2018-10-27 19:55:44 |
| 6 | 无花果 | 100 | 8.760 | 1 | 无 | 2018-10-27 19:57:48 | 2018-10-27 19:57:48 |
| 7 | 山葡萄 | 200 | 5.550 | 1 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 |
| 9 | 五敛子 | 12 | 6.010 | 0 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 |
| 10 | 藕 | 80 | 10.200 | 0 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 |
| 12 | 龙眼 | 49 | 6.540 | 0 | NULL | 2018-10-27 20:24:01 | 2018-10-27 20:24:01 |
| 13 | 楂子 | 0 | 8.100 | 0 | NULL | 2018-10-27 20:24:01 | 2018-10-27 20:24:01 |
+----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+
11 rows in set (0.00 sec)
mysql> select * from t_fruit where not(count = 5);
+----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+
| id | name | count | price | is_sales | note | gmt_create | gmt_modified |
+----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+
| 1 | 甜瓜 | 10 | 3.210 | 1 | 无 | 2018-10-27 19:42:56 | 2018-10-27 19:42:56 |
| 2 | 乌梅 | 20 | 5.430 | 1 | 无 | 2018-10-27 19:46:21 | 2018-10-27 19:46:21 |
| 3 | 樱桃 | 30 | 6.540 | 1 | 无 | 2018-10-27 19:46:48 | 2018-10-27 19:46:48 |
| 4 | 甘蔗 | 50 | 7.650 | 0 | 无 | 2018-10-27 19:51:13 | 2018-10-27 19:51:13 |
| 5 | 菠萝蜜 | 50 | 8.760 | 1 | 菠萝蜜和菠萝是什么关系? | 2018-10-27 19:55:44 | 2018-10-27 19:55:44 |
| 6 | 无花果 | 100 | 8.760 | 1 | 无 | 2018-10-27 19:57:48 | 2018-10-27 19:57:48 |
| 7 | 山葡萄 | 200 | 5.550 | 1 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 |
| 9 | 五敛子 | 12 | 6.010 | 0 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 |
| 10 | 藕 | 80 | 10.200 | 0 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 |
| 12 | 龙眼 | 49 | 6.540 | 0 | NULL | 2018-10-27 20:24:01 | 2018-10-27 20:24:01 |
| 13 | 楂子 | 0 | 8.100 | 0 | NULL | 2018-10-27 20:24:01 | 2018-10-27 20:24:01 |
+----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+
11 rows in set (0.00 sec)
mysql> exit
Bye
stu@Ubuntu:~$
mysql> select * from t_fruit where note <> '无';
+----+-----------+-------+-------+----------+------------------------------------+---------------------+---------------------+
| id | name | count | price | is_sales | note | gmt_create | gmt_modified |
+----+-----------+-------+-------+----------+------------------------------------+---------------------+---------------------+
| 5 | 菠萝蜜 | 50 | 8.760 | 1 | 菠萝蜜和菠萝是什么关系? | 2018-10-27 19:55:44 | 2018-10-27 19:55:44 |
+----+-----------+-------+-------+----------+------------------------------------+---------------------+---------------------+
1 row in set (0.00 sec)
MySQL是关系型数据库管理系统,目前是开源的(2019-02)。
明确权限,恰当地选择引擎与字符集等,规范命名。
MariaDB,Redis,MongoDB,PostgreSQL,Hive,HBase等,多作了解,拓宽心量。
Workbench,phpMyAdmin,Navicat等图形化管理工具,豫兮若冬涉川。