- OS : Ubuntu 18.04.1 LTS
- DBMS : mysql 8.0.12
- blog : blog.csdn.net/shiwanwu
- github : github.com/GratefulHeartCoder
- typesetting : Markdown
数据,数据,命根就在数据 ! 操作数据库时,一定要谨慎小心。师万物 这里的代码看看就好,要有自己的判断。遇到抉择,要不耻上下问。
example
stu@Ubuntu:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 27
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> create table `t_fruit`(
-> `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键,自增长',
-> `name` varchar(15) NOT NULL COMMENT '名称,唯一',
-> `count` int(11) NOT NULL COMMENT '数量',
-> `price` decimal(6,3) NOT NULL COMMENT '每两价格',
-> `is_sales` tinyint(1) not null default 1 comment'销售状态,1为正在销售,0为停售',
-> `note` varchar(255) default '无' comment'备注,默认:无',
-> `gmt_create` datetime NOT NULL COMMENT '创建时间',
-> `gmt_modified` datetime NOT NULL COMMENT '最后修改时间',
-> PRIMARY KEY (`id`),
-> UNIQUE KEY `name` (`name`)
-> )
-> ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='果部药物表';
Query OK, 0 rows affected (0.13 sec)
mysql> show full fields from t_fruit;
+--------------+------------------+--------------------+------+-----+---------+----------------+---------------------------------+--------------------------------------------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+--------------+------------------+--------------------+------+-----+---------+----------------+---------------------------------+--------------------------------------------+
| id | int(10) unsigned | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | 主键,自增长 |
| name | varchar(15) | utf8mb4_0900_ai_ci | NO | UNI | NULL | | select,insert,update,references | 名称,唯一 |
| count | int(11) | NULL | NO | | NULL | | select,insert,update,references | 数量 |
| price | decimal(6,3) | NULL | NO | | NULL | | select,insert,update,references | 每两价格 |
| is_sales | tinyint(1) | NULL | NO | | 1 | | select,insert,update,references | 销售状态,1为正在销售,0为停售 |
| note | varchar(255) | utf8mb4_0900_ai_ci | YES | | 无 | | select,insert,update,references | 备注,默认:无 |
| gmt_create | datetime | NULL | NO | | NULL | | select,insert,update,references | 创建时间 |
| gmt_modified | datetime | NULL | NO | | NULL | | select,insert,update,references | 最后修改时间 |
+--------------+------------------+--------------------+------+-----+---------+----------------+---------------------------------+--------------------------------------------+
8 rows in set (0.01 sec)
mysql> exit
Bye
stu@Ubuntu:~$
reference
resource
- [手册] https://dev.mysql.com/doc/
- [源码] https://downloads.mysql.com/archives/community/
- [Bug ] https://bugs.mysql.com/
- [ 测试数据 ] https://github.com/datacharmer/test_db
- [规范 - 参考] https://yq.aliyun.com/articles/69327
- [排名 - 参考] https://db-engines.com/en/
- [平台] https://www.csdn.net/
MySQL是一个关系型数据库管理系统,目前是开源的(2018-10)。
权限明确,恰当选择引擎与字符集,命名简洁明了与规范。
MariaDB,Redis,MongoDB,PostgreSQL,Hive,HBase等,可以简单地了解。
Workbench,phpMyAdmin,Navicat等图形化管理工具,可以试用一下。