- OS : Ubuntu 18.04.1 LTS
- DBMS : mysql 8.0.12
示例
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:~$
复制
参考资料
学习资源
欢迎各位同学一起来交流学习心得!
最后修改时间:2021-12-16 18:00:22
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
文章被以下合辑收录
评论
相关阅读
【专家有话说第五期】在不同年龄段,DBA应该怎样规划自己的职业发展?
墨天轮编辑部
1327次阅读
2025-03-13 11:40:53
MySQL8.0统计信息总结
闫建(Rock Yan)
500次阅读
2025-03-17 16:04:03
2月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
469次阅读
2025-03-13 14:38:19
SQL优化 - explain查看SQL执行计划(一)
金同学
397次阅读
2025-03-13 16:04:22
MySQL突然崩溃?教你用gdb解剖core文件,快速锁定“元凶”!
szrsu
377次阅读
2025-03-13 00:29:43
MySQL生产实战优化(利用Index skip scan优化性能提升257倍)
chengang
330次阅读
2025-03-17 10:36:40
MySQL数据库当前和历史事务分析
听见风的声音
302次阅读
2025-04-01 08:47:17
MySQL 生产实践-Update 二级索引导致的性能问题排查
chengang
250次阅读
2025-03-28 16:28:31
一键装库脚本3分钟极速部署,传统耗时砍掉95%!
IT邦德
240次阅读
2025-03-10 07:58:44
墨天轮个人数说知识点合集
JiekeXu
236次阅读
2025-04-01 15:56:03