数据库 – SQLite3的动态打字

前端之家收集整理的这篇文章主要介绍了数据库 – SQLite3的动态打字前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
与其他风格的sql相比,sqlite3使用动态类型而不是静态类型. SQLite website读:

Most sql database engines (every sql database engine other than sqlite,as far as we know) uses static,rigid typing. With static typing,the datatype of a value is determined by its container – the particular column in which the value is stored.

sqlite uses a more general dynamic type system. In sqlite,the datatype of a value is associated with the value itself,not with its container.

在我看来,这正是你不想要的,因为它可以让你存储整数列的字符串.

页面继续:

…the dynamic typing in sqlite allows it to do things which are not possible in traditional rigidly typed databases.

我有两个问题:

>用例问题:什么是sqlite3的动态打字有益的一些例子?
>历史/设计问题:使用动态打字实现sqlite的动机是什么?

解决方法

这在sqlite中称为 type affinity.

根据sqlite网站,他们已经完成了“为了最大限度地提高sqlite和其他数据库引擎之间的兼容性”. (见上面的链接)

sqlite supports the concept of “type affinity” on columns. The type affinity of a column is the recommended type for data stored in that column. The important idea here is that the type is recommended,not required. Any column can still store any type of data. It is just that some columns,given the choice,will prefer to use one storage class over another. The preferred storage class for a column is called its “affinity”.

我的理解是,sqlite正是它的命名 – 一个非常轻量级的简约数据库引擎.与强类型相关联的开销可能超出了项目的范围,最好留给使用sqlite的应用程序.

但是再次,根据他们的网站,他们已经做到了这一点,以最大限度地发挥与其他DB引擎的兼容性.

猜你在找的MsSQL相关文章