关于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.

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值