如上面的创建表语句,字段 s_no 和 s_name 后面通过关键字 comment 来给对应的字段添加注释。
前言 有朋友在后台留言。希望我能说说我在数据库表设计时踩过的坑。那么,我们今天就来聊聊我在数据库表设计时踩过的坑,以及现在对数据库表设计的一点建议。希望能够帮助到你。 utf8的锅 经验提示: 在设计数据表时,一定要注意该字段存储的内容,如果允许设置表情,则一定不能使用utf8,而是使用utf8mb4。 选择合适的类型 在数据库表设计时,字段的类型还真不好设计,这里简单说说: 保存手机号的字段,用varchar(20)就已经足够了,就不应该设计为varchar(100),设置为varchar(100)只会消
背景:一个平台或系统随着时间的推移和用户量的增多,数据库操作往往会变慢;而在Java应用开发中数据库更是尤为重要,绝大多数情况下数据库的性能决定了程序的性能,如若前期埋下的坑越多到后期数据库就会成为整个系统的瓶颈;因此,更规范化的使用MySQL在开发中是不可或缺的。
一个平台或系统随着时间的推移和用户量的增多,数据库操作往往会变慢;而在Java应用开发中数据库更是尤为重要,绝大多数情况下数据库的性能决定了程序的性能,如若前期埋下的坑越多到后期数据库就会成为整个系统的瓶颈;因此,更规范化的使用MySQL在开发中是不可或缺的。
事务(transaction)是由一系列操作序列构成的程序执行单元,这些操作要么都做,要么都不做,是一个不可分割的工作单位。
逛博客的时候,发现了一个很有意思的文章:数据库表结构导出工具。带着好奇,我也去DIY了一个,先看看效果:
像代码一样,可以为表以及表中的列添加注释,方便其他人知晓其功能。对于一些字段,在经过一定时间后,创建者未必也能想起其具体的含意,所以注释显得尤为重要。
来源:andyqian www.andyqian.com/2017/11/11/database/MySQLConvert/ 前言 今天我们继续回到MySQL系列文章中,谈一谈MySQL中隐式类型转换。(其实我最早知道是在慢SQL优化中知道隐式类型转换概念的),在说隐式类型转换之前,首先我们通过一个实例来看看是怎么回事。 数据结构 本文中所有的操作,都是基于该数据结构(有兴趣的童鞋可以实验): create table t_base_user( oid bigint(20)notnullprimary ke
最近改用ER\Studio建模,发现ER\Studio居然不支持生成mysql列注释,看网上都说勾选即可,然后生成mysql时并没有那个勾选项,试了下生成Oracle和DB2是支持的...
有时候你需要再 SQL 执行之前对于 SQL 语句进行改写,有可能是修改表名字段名,有可能只是添加注释,这些看起来奇怪的操作其实有时候是为了帮助在数据库之前的 proxy 来实现某些功能,比如最常见的分库分表,读写分离,多租户等等。
MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品。MySQL 是最流行的关系型数据库管理系统之一。简而言之数据库用来存储数据。
没有特殊要求(即 Innodb 无法满足的功能如:列存储,存储空间数据等)的情况下,所有表必须使用 Innodb 存储引擎(MySQL5.5 之前默认使用 Myisam,5.6 以后默认的为 Innodb)。
添加注释 ctrl + v 进入块选泽模式。 上下键选中需要注释的行。 按大写 I 进入插入模式,输入注释符。 按两次 ESC 退出,即完成添加注释。 取消注释 ctrl + v 进入块选泽模式。 上下键选中需要注释的行。 按小写 x 删除注释符。 按 ESC 退出,即完成取消注释。 热情推荐: 技术博客: 硬核后端技术干货,内容包括 Python、Django、Docker、Go、Redis、ElasticSearch、Kafka、Linux 等。 Go 程序员: Go 学习路线图,包括基础专栏,进阶
--add-drop-database 每个数据库创建之前添加drop数据库语句。
最近一直在更新《Java 成长计划》这个专栏,主要是 Java 全流程学习的一个记录,目前已经更新到 Java 并发多线程部分,后续会继续更新;而今天准备开设一个全新的专栏 《EfficientFarm》。
DataGrip 是一款数据库管理客户端工具,方便的连接到数据库服务器,执行sql语句、创建表、创建索引以及导出数据等。
命名规范 库名、表名、字段名必须使用小写字母,并采用下划线分割 库名、表名、字段名禁用超过32个字符。须见名知意 库名、表名、字段名禁用使 MySQL保留字 临时库、表名必须以tmp为前缀,并以日期为后缀 备份库、表必须以bak为前缀,并以日期为后缀 基础规范 使用INNODB存储引擎 表字符集使用utf8mb4 所有表都需要添加注释 单表数据量建议控制在5000W以内 不在数据库中存储图片、文件等大数据 禁止在线上做数据库压力测试 禁止从测试、开发环境直连数据库 库表设计 禁止使用分区表 拆分大字段和访问
提示我写错了,仔细看一看,原来是auto_increment被我少写了一个e。
Camel(驼峰式): 大小写形式-除了第一个单词,所有单词第一个字母大写,其他字母小写。 Pascal(帕斯卡): 大小写形式-所有单词第一个字母大写,其他字母小写。
一个程序的可读性,关键取决于注释。如果一个程序想二次开发,要读懂前面的程序代码,就必须在程序中有大量的注释文档,所以对于一个优秀的程序员来说,学会在程序中适当地添加注释是非常重要的。
代码风格没有正确与否,重要的是整齐划一,这是我拟的一份《.Net 项目代码风格参考》,供大家参考。
MySQLdump是一个数据库逻辑备份程序,可以使用对一个或者多个mysql数据库进行备份或者将数据传输到其他mysql服务器。执行mysqldump时需要账户拥有select权限才可以进行备份数据表,show view权限用于备份视图,trigger权限用于备份触发器等。
携手创作,共同成长!这是我参与「掘金日新计划 · 8 月更文挑战」的第11天,点击查看活动详情
之前我们在写项目的实体类的时候,只是简单的写一个实体类,但是现在我们想要让实体类在swagger界面显示,
小菜就是小菜,几个人搞出来的项目,让公司大牛稍微看了下,最后送出了惨不忍睹四个字。命名各种各样,五花八门,大写英文、小写英文、大写拼音、小写拼音、英文和拼音组合、字母和特殊字符(下划线等)组合。这样的项目代码要是让人来维护或者添加功能、查找bug会头痛欲裂。也没办法谁叫咱们是小菜呢?而且程序员最头疼的事:http://kb.cnblogs.com/page/192017/这篇知识博文里,最终的结果居然是命名。所以……
constraint可以给键进行重命名,但是在数据字典中,主键名还是显示primary
后台服务通过接口(如 RESTful API)对外提供服务时,需要有明确的接口文档。
本公众号提供的工具、教程、学习路线、精品文章均为原创或互联网收集,旨在提高网络安全技术水平为目的,只做技术研究,谨遵守国家相关法律法规,请勿用于违法用途,如果您对文章内容有疑问,可以尝试加入交流群讨论或留言私信,如有侵权请联系小编处理。
启动项目运行 浏览器输入 http://localhost:8080/swagger-ui.html
1) 使用InnoDB存储引擎 2) 数据库字符集使用UTF8,校对字符集使用utf8_general_ci 3) 所有表、字段都尽量添加注释 4) 库名、表名、字段名使用小写字母,禁止超过32个字符,须见名知意 5) 非唯一索引以 “idx_字段1_字段2” 命名,唯一索引必须以 “uniq_字段1_字段2” 命名
上一篇文章中介绍了使用Swagger生成接口文档,非常方便,功能也十分强大。如果非要说Swaager有什么缺点,想必就是注解写起来比较麻烦。如果我说有一款不用写注解,就可以生成文档的工具,你心动了吗?他就是我们今天的主角——JApiDocs。
swagger想必大家都用过吧,非常方便,功能也十分强大。如果要说swaager有什么缺点,想必就是注解写起来比较麻烦。如果我说有一款不用写注解,就可以生成文档的工具,你心动了吗?他就是我们今天的主角——JApiDocs。
swagger想必大家都用过吧,非常方便,功能也十分强大。如果要说swagger有什么缺点,想必就是注解写起来比较麻烦。如果我说有一款不用写注解,就可以生成文档的工具,你心动了吗?他就是我们今天的主角——JApiDocs。
上一篇文章中已经介绍过swagger了,非常方便,功能也十分强大。如果非要说Swaager有什么缺点,想必就是注解写起来比较麻烦。如果我说有一款不用写注解,就可以生成文档的工具,你心动了吗?他就是我们今天的主角——JApiDocs。
SQLMap是一个自动化的SQL注入工具,其主要功能是扫描,发现并利用给定的url的SQL注入漏洞内置很多绕过插件,支持MySQL, Oracle,PostgreSQL, Microsoft SQL Server, Microsoft Access, IBM DB2, SQLite, Firebird,Sybase和SAP MaxDB等数据库的各种安全漏洞检测。
上一章:商城接口文档:第一章:简洁版接口文档。花了二天搞了一个比较简洁的接口文档,浪费时间不说,写的也不太好,不满意。这一章使用Swagger接口的文档在线自动生成省下不少时间,而且很规范。 导入Maven
在一个数据库仓库可以创建多个数据库,一个数据库可以创建多张表,基于表存储数据的数据库叫做:关系型数据库。
MySQL限制每个表最多存储4096列,并且每一行数据的大小不能超过65535字节 减少磁盘IO,保证热数据的内存缓存命中率(表越宽,把表装载进内存缓冲池时所占用的内存也就越大,也会消耗更多的IO) 更有效的利用缓存,避免读入无用的冷数据 经常一起使用的列放到一个表中(避免更多的关联操作)
utf8mb4是utf8的超集,emoji表情以及部分不常见汉字在utf8下会表现为乱码。
二、对表的修改 1.给表重命名 语法:alter table table_name rename to new_table_name; 例子:alter table student rename to new_student; 2.给表添加字段 语法:alter table tablename add (column datatype [default value][null/not null],….); 例子: alter table student add (teachername varchar2(30) default ‘张三’ not null); 3.修改表字段 语法:alter table tablename modify (column datatype [default value][null/not null],….); 例子:alter table student modify (teachername varchar2(30) default ‘张三’ not null); 4.删除表字段 语法:alter table tablename drop (column); 或者alter table tablename drop column column_name 例子:alter table student drop column teachername; 5.主键约束 添加有名称的主键约束:alter table table_name add constraint pk_name primary key (id); 删除有名称的主键约束:alter table table_name drop constraint pk_name; 6.修改表字段类型 例子:alter table student alter column birthday decimal(18, 4) not null
设置注释模板的入口:Window->Preference->Java->Code Style->Code Template 然后展开Comments节点就是所有需设置注释的元素。
SQLE 是由上海爱可生信息技术股份有限公司 开发并开源,支持SQL审核、索引优化、事前审核、事后审核、支持标准化上线流程、原生支持 MySQL 审核且数据库类型可扩展的 SQL 审核工具。
就职于捷信消费金融有限公司,担任 DBA 工作。先后从事过 oracle 、mongo 、mysql 的 DBA ,以及大数据 ETL 的开发工作。对 NEWSQL 以及云原生分布式数据库具有浓厚的兴趣爱好。
所有的数据库对象名称必须使用小写字母并用下划线分割(MySQL大小写敏感,名称要见名知意,最好不超过32字符) 禁止在数据中存储图片,文件二进制数据(使用文件服务器)
mysqldump -uroot -p --all-databases --all-tablespaces
] 10. 表字段注释,每个字段必须设置注释说明; 11. 表字段注释,状态类型的字段必须说明取值规则(比如性别sex取值规则)
公司开发新系统,需要创建几百个数据库表,建表的规则已经写好放到Excel中,如果手动创建的话需要占用较长的时间去做,而且字段类型的规则又被放到了另一张表,如果手动去一个一个去匹配就很麻烦,所以我先把两张表都导入数据库中,建表的数据如下:
MySQL对象名默认规定大小写敏感,且在生产环境中MySQL通常运行在Linux系统下,Linux系统本身也是大小写敏感的。
SQL注入并不是很精通,通过实战绕过WAF来进行加强SQL注入能力,希望对正在学习的师傅能有一丝帮助。
领取专属 10元无门槛券
手把手带您无忧上云