网站首页 > 博客文章 正文
欢迎来到MySQL实战第14篇,修炼500篇成为MySQL高手!
在完整性的约束下,在实际工作中如何设计表的结构?
1.用户表imoor_user
create table if not exists imooc_user(
id int unsigned auto_increment key comment '用户编号',
username varchar(20) not null unique comment '用户名',
password char(32) not null comment '密码',
email varchar(50) not null unique comment'邮箱',
age tinyint unsigned not null unique default 18 comment'年龄',
sex enum('男','女','保密') not null default '保密' comment'性别',
tel char(11) not null unique comment'电话',
addr varchar(50) not null default '北京' comment'地址',
card char(18) not null unique comment'身份证号',
married tinyint(1) not null default 0 comment'0代表未结婚,1代表已结婚',
salary float(8,2) not null default 0 comment'薪水'
)engine=innodb default charset =utf8;
2.表的结构
desc imooc_user;
3.财务总监分析完整性
<1>key:本质是primary key,主键(PK),标识该字段为该表的主键,可以唯一的标识记录,不能重复,不能为空。
<2>not null 标识该字段不能为空,没有标记为非空的字段,默认是可以为空的。
<3>unique key(UK):标识该字段的值是唯一的,一个表中只能有一个主键,但是可以有多个唯一(null 是不算重复的)
<4>auto_increment:标识该字段的值自动增长(整数类型,而且为主键),一个表中只能有一个自增长字段,而且一定要配合主键使用,自增长字段一定是主键,但主键不一定是自增长的。
<5>default: 为该字段设置默认值
<6>unsigned: 无符号
<7>comment :字段或列的注释
关注财务总监的数据分析,修炼MySQL,做个懂数据的人!
猜你喜欢
- 2024-09-29 谈下最近开发中用了一下Mysql的set字段类型
- 2024-09-29 软件测试必备之数据库知识(软件测试数据库面试题及答案2020)
- 2024-09-29 越晚搞懂 MySQL JSON 数据类型,你就越吃亏
- 2024-09-29 主键简介1(主键是什么)
- 2024-09-29 资深开发竟然不清楚int(1)和int(10)的区别
- 2024-09-29 面试突击59:一个表中可以有多个自增列吗?
- 2024-09-29 MySQL实战——表结构设计之数字类型
- 2024-09-29 性能测试告诉你 mysql 数据库存储引擎该如何选?
- 2024-09-29 java常见疑难面试题及答案(阿里、蚂蚁、百度、美团)(三)
- 2024-09-29 Mysql的两种存储引擎基础讲解(mysql有哪些存储引擎,各自优缺点)
你 发表评论:
欢迎- 07-08Google Cloud Platform 加入支持 Docker 的容器引擎
- 07-08日本KDDI与Google Cloud 签署合作备忘录,共探AI未来
- 07-08美国Infoblox与Google Cloud合作推出云原生网络和安全解决方案
- 07-08GoogleCloud为Spanner数据库引入HDD层,将冷存储成本降低80%
- 07-08谷歌推出Cloud Dataproc,缩短集群启动时间
- 07-08Infovista与Google Cloud携手推进射频网络规划革新
- 07-08比利时Odoo与Google Cloud建立增强合作,扩大全球影响力
- 07-08BT 和 Google Cloud 通过 Global Fabric 加速 AI 网络
- 最近发表
-
- Google Cloud Platform 加入支持 Docker 的容器引擎
- 日本KDDI与Google Cloud 签署合作备忘录,共探AI未来
- 美国Infoblox与Google Cloud合作推出云原生网络和安全解决方案
- GoogleCloud为Spanner数据库引入HDD层,将冷存储成本降低80%
- 谷歌推出Cloud Dataproc,缩短集群启动时间
- Infovista与Google Cloud携手推进射频网络规划革新
- 比利时Odoo与Google Cloud建立增强合作,扩大全球影响力
- BT 和 Google Cloud 通过 Global Fabric 加速 AI 网络
- NCSA和Google Cloud合作开发AI驱动的网络防御系统,加强泰国网络空间的安全性
- SAP将在沙特阿拉伯 Google Cloud 上推出BTP服务
- 标签列表
-
- ifneq (61)
- 字符串长度在线 (61)
- googlecloud (64)
- messagesource (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)