设为首页 收藏本站
查看: 1100|回复: 0

[经验分享] sqlite所支持的数据类型

[复制链接]

尚未签到

发表于 2016-11-30 10:35:40 | 显示全部楼层 |阅读模式
  上次工作需要学了一个月的mysql,不久知道好多东西都忘掉了,现在由于工作需要再学点sqlite,其实都差不多,摘抄了两篇博客园的文章放在这里了~虽然表的是原创,但是还是给吃两个出处:这里 和 这里

  Sqlite3支持的数据类型

  NULL,INTEGER,REAL,TEXT,BLOB

以及:
smallint 16 位元的整数。
interger 32 位元的整数。
decimal(p,s) p 精确值和 s 大小的十进位整数,精确值p是指全部有几个数(digits)大小值,s是指小数点後有几位数。如果没有特别指定,则系统会设为 p=5; s=0 。
float 32位元的实数。
double 64位元的实数。
char(n) n 长度的字串,n不能超过 254。
varchar(n) 长度不固定且其最大长度为 n 的字串,n不能超过 4000。
graphic(n) 和 char(n) 一样,不过其单位是两个字元 double-bytes, n不能超过127。这个形态是为了支援两个字元长度的字体,例如中文字。
vargraphic(n) 可变长度且其最大长度为 n 的双字元字串,n不能超过 2000
date 包含了 年份、月份、日期。
time 包含了 小时、分钟、秒。
  timestamp 包含了 年、月、日、时、分、秒、千分之一秒。
  表1-1

typedescriptionTINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB, BYTEAString types of unlimited length. Binary data must be safely encoded, see text.CHAR(), VARCHAR(), TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXTString types of unlimited length. There is no chopping or padding performed by the database engine.ENUMString type of unlimited length. In contrast to MySQL, choosing ENUM over VARCHAR does not save any storage space.SETString type of unlimited length. In contrast to MySQL, the input is not checked against the list of allowed values.YEARString type of unlimited length. MySQL stores 2 or 4 digit years as a 1 byte value, whereas the SQLite drivers stores the string as provided.TINYINT, INT1, CHARA 1 byte type used to store one character, a signed integer between -128 and 127, or an unsigned integer between 0 and 255.SMALLINT, INT22 byte (short) integer type used to store a signed integer between -32768 and 32767 or an unsigned integer between 0 and 65535.MEDIUMINT3 byte integer type used to store a signed integer between -8388608 and 8388607 or an unsigned integer between 0 and 16777215.INT, INTEGER, INT44 byte (long) integer type used to store a signed integer between -2147483648 and 2147483647 or an unsigned integer between 0 and 4294967295.BIGINT, INT8, INTEGER PRIMARY KEY8 byte (long long) integer type used to store a signed integer between -9223372036854775808 and 9223372036854775807 or an unsigned integer between 0 and 18446744073709551615. See below for a discussion of INTEGER PRIMARY KEY.DECIMAL, NUMERICA string type of unlimited length used to store floating-point numbers of arbitrary precision.TIMESTAMP, DATETIMEA string type of unlimited length used to store date/time combinations. The required format is 'YYYY-MM-DD HH:MM:SS', anything following this pattern is ignored.DATEA string type of unlimited length used to store a date. The required format is 'YYYY-MM-DD', anything following this pattern is ignored.TIMEA string type of unlimited length used to store a time. The required format is 'HH:MM:SS', anything following this pattern is ignored.FLOAT, FLOAT4, REALA 4 byte floating-point number. The range is -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38. Please note that MySQL treats REAL as an 8 byte instead of a 4 byte float like PostgreSQL.DOUBLE, DOUBLE PRECISION, FLOAT8An 8 byte floating-point number. The range is -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-307616-1-1.html 上篇帖子: android 单元测试, 以sqlite测试为例 下篇帖子: ocos2d-x中使用sqlite数据库
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表