问题描述
我可以在 SQLite 网站上找到语法图表",但没有示例,我的代码崩溃了.我有其他表在单个列上具有唯一约束,但我想在两列上向表添加约束.这就是我所拥有的导致 SQLiteException 消息语法错误"的原因.
I can find syntax "charts" on this on the SQLite website, but no examples and my code is crashing. I have other tables with unique constraints on a single column, but I want to add a constraint to the table on two columns. This is what I have that is causing an SQLiteException with the message "syntax error".
CREATE TABLE name (column defs)
UNIQUE (col_name1, col_name2) ON CONFLICT REPLACE
我这样做是基于以下几点:
I'm doing this based on the following:
表格约束
要清楚,我提供的链接上的文档说CONTSTRAINT name 应该在我的约束定义之前.
To be clear, the documentation on the link I provided says that CONTSTRAINT name should come before my constraint definition.
不过,可能会导致解决方案的一些事情是,在我括号中的列定义之后的任何内容都是调试器所抱怨的.
Something that may lead to the solution though is that whatever follows my parenthesized column definitions is what the debugger complains about.
如果我把
...last_column_name last_col_datatype) CONSTRAINT ...
错误在靠近CONSTRAINT":语法错误
如果我把
...last_column_name last_col_datatype) UNIQUE ...
错误在UNIQUE"附近:语法错误
推荐答案
将 UNIQUE 声明放在列定义部分;工作示例:
Put the UNIQUE declaration within the column definition section; working example:
CREATE TABLE a (
i INT,
j INT,
UNIQUE(i, j) ON CONFLICT REPLACE
);
这篇关于SQLite 表约束 - 在多列上唯一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)