相关的 SQLite 数据类型(如 INT、INTEGER、SMALLINT 和 TINYINT)之间有什么区别? [英] What is the difference between related SQLite data-types like INT, INTEGER, SMALLINT and TINYINT?

查看:48
本文介绍了相关的 SQLite 数据类型(如 INT、INTEGER、SMALLINT 和 TINYINT)之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 SQLite3 中创建表时,当我遇到所有可能的暗示内容相似的数据类型时,我感到困惑,所以有人能告诉我以下数据类型之间的区别吗?

When creating a table in SQLite3, I get confused when confronted with all the possible datatypes which imply similar contents, so could anyone tell me the difference between the following data-types?

INT, INTEGER, SMALLINT, TINYINT

DEC, DECIMAL

LONGCHAR, LONGVARCHAR

DATETIME, SMALLDATETIME

是否有一些文档列出了最小值/最大值.各种数据类型的容量?例如,我猜 smallint 拥有比 tinyint 更大的最大值,但比整数更小,但我不知道这些容量是什么.

Is there some documentation somewhere which lists the min./max. capacities of the various data-types? For example, I guess smallint holds a larger maximum value than tinyint, but a smaller value than integer, but I have no idea of what these capacities are.

推荐答案

SQLite,技术上来说,没有数据类型,有存储类在清单类型系统中,是的,如果您习惯于传统的RDBMSes,这会令人困惑.在内部,所有内容都存储为文本.数据类型会根据相关性(分配给列的数据类型)被强制/转换为各种存储位置.

SQLite, technically, has no data types, there are storage classes in a manifest typing system, and yeah, it's confusing if you're used to traditional RDBMSes. Everything, internally, is stored as text. Data types are coerced/converted into various storage locations based on affinities (ala data types assigned to columns).

我建议您做的最好的事情是:

The best thing that I'd recommend you do is to :

  1. 暂时忘记您曾经了解的有关独立数据库数据类型的所有信息

  1. Temporarily forget everything you used to know about standalone database datatypes

SQLite 站点阅读上述链接.

Read the above link from the SQLite site.

根据旧架构获取类型,然后查看它们在 SQLite

Take the types based off of your old schema, and see what they'd map to in SQLite

将所有数据迁移到 SQLite 数据库.

Migrate all the data to the SQLite database.

注意:数据类型限制可能很麻烦,尤其是当您在 SQL 中添加持续时间、日期或此类性质的内容时.SQLite 很少有内置函数来处理这类事情.但是,SQLite 确实为您提供了一种简单的方法来创建自己的内置函数,通过 sqlite3_create_function 库函数.您可以使用该工具代替传统的存储过程.

Note: The datatype limitations can be cumbersome, especially if you add time durations, or dates, or things of that nature in SQL. SQLite has very few built-in functions for that sort of thing. However, SQLite does provide an easy way for you to make your own built-in functions for adding time durations and things of that nature, through the sqlite3_create_function library function. You would use that facility in place of traditional stored procedures.

这篇关于相关的 SQLite 数据类型(如 INT、INTEGER、SMALLINT 和 TINYINT)之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆