关于sqlite中primary key可以输入null的说明

前端之家收集整理的这篇文章主要介绍了关于sqlite中primary key可以输入null的说明前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

按照sql标准,主键(PRIMARY KEY)应该暗含NOT NULL,不幸地是,在sqlite中,因为长久以来的编码疏忽,导致 主键可以是NULL的. 我们可以修改sqlite让它符合标准(我们应该在未来这么做),但是 sqlite使用得太广泛,如果修正这个问题,我们担心会搞坏一些旧有的代码. 所以,创建不能为NULL的主键时,应该使用 PRIMARY KEY NOT NULL 会比较可靠 原文如下: According to the sql standard,PRIMARY KEY should imply NOT NULL. Unfortunately,due to a long-standing coding oversight,this is not the case in sqlite. sqlite allows NULL values in a PRIMARY KEY column. We could change sqlite to conform to the standard (and we might do so in the future),but by the time the oversight was discovered,sqlite was in such wide use that we feared breaking legacy code if we fixed the problem. So for now we have chosen to continue allowing NULLs in PRIMARY KEY columns. Developers should be aware,however,that we may change sqlite to conform to the sql standard in future and should design new programs accordingly.

原文链接:https://www.f2er.com/sqlite/202735.html

猜你在找的Sqlite相关文章