在设计数据库的时候,整数类型的使用时不可避免的如ID,类型等。
在选择整数的同时主要是考虑是数据范围,如是否带符号,最大存储值。
一、有误符号
在无符号unsigned类型比有符号的整数多一倍。
如
tinyint 范围 -128~127
tinyint unsigned 范围 0~255
这里的tinyint unsigned比tinyint 最大数多一倍,其它的同理。
如
果我们的范围 1-200,如果使用带符号的整数 tinyint是不能满足的,使用只有选择更宽的字段但使用tinyint unsigned就可以满足。
二、整数范围
tinyint ~百
smallint ~万
mediumint ~千万
int ~10亿
bigint ~ 10亿x10亿
数据详情范围
tinyint 8 bits 0 ~ 255 -128 ~ 127smallint 16 bits 0 ~ 65535 -32768 ~ 32767
mediumint 24 bits 0 ~ 16777216 -8388608 ~ 8388607
int 32 bits 0 ~ 4294967295 -2147483648 ~ 2147483647
bigint 64 bits 0 ~ 18446744073709551615 -9223372036854775808 ~ 9223372036854775807
三、如何选择
这里的数据主要是大楷的数据范围比如100左右用tinyint ,有时我们需要通过计算,比如我们发布的一片新闻
统计它的访问量,如:1000(日访问量)*365(天)*10(年)=36500000(千万) 这是数据是大于mediumint,而在int范围类
但如果我们考虑一下,一篇新闻能到日访问量到1000而且持续10年,如果能那就选择int,如果可能性不大mediumint可能是最好的选择。
有时我们都图略的这些范围的分析,反正只要是整数,要么int或者bigint。在不是很影响性能的情况下,节约设计分析。
当时还有一个设计误区其实用 int(x)来作为整数范围,原来发布过相应的博客数据库-整数类型宽度—int(3)与int(11)区别 来论证过!
原文地址: http://blog.yi18.net/articles/2014/04/06/1396777140197.html
mysqlviewshavelimitations:1)他们不使用Supportallsqloperations,限制DatamanipulationThroughViewSwithJoinSorsubqueries.2)他们canimpactperformance,尤其是withcomplexcomplexclexeriesorlargedatasets.3)

porthusermanagementInmysqliscialforenhancingsEcurityAndsingsmenting效率databaseoperation.1)usecReateusertoAddusers,指定connectionsourcewith@'localhost'or@'%'。

mysqldoes notimposeahardlimitontriggers,butacticalfactorsdeterminetheireffactective:1)serverConfiguration impactactStriggerGermanagement; 2)复杂的TriggerSincreaseSySystemsystem load; 3)largertablesslowtriggerperfermance; 4)highConconcConcrencerCancancancancanceTigrignecentign; 5); 5)

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

通过PHP网页界面添加MySQL用户可以使用MySQLi扩展。步骤如下:1.连接MySQL数据库,使用MySQLi扩展。2.创建用户,使用CREATEUSER语句,并使用PASSWORD()函数加密密码。3.防止SQL注入,使用mysqli_real_escape_string()函数处理用户输入。4.为新用户分配权限,使用GRANT语句。

mysql'sblobissuitableForStoringBinaryDataWithInareLationalDatabase,而alenosqloptionslikemongodb,redis和calablesolutionsoluntionsoluntionsoluntionsolundortionsolunsolunsstructureddata.blobobobsimplobissimplobisslowderperformandperformanceperformancewithlararengelitiate;

toaddauserinmysql,使用:createUser'username'@'host'Indessify'password'; there'showtodoitsecurely:1)choosethehostcarecarefullytocon trolaccess.2)setResourcelimitswithoptionslikemax_queries_per_hour.3)usestrong,iniquepasswords.4)Enforcessl/tlsconnectionswith

toAvoidCommonMistakeswithStringDatatatPesInMysQl,CloseStringTypenuances,chosethirtightType,andManageEngencodingAndCollationsEttingsefectery.1)usecharforfixed lengengters lengengtings,varchar forbariaible lengength,varchariable length,andtext/blobforlabforlargerdata.2 seterters seterters seterters seterters


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver Mac版
视觉化网页开发工具

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

Dreamweaver CS6
视觉化网页开发工具