1. <legend id='sRLhY'><style id='sRLhY'><dir id='sRLhY'><q id='sRLhY'></q></dir></style></legend>

  2. <small id='sRLhY'></small><noframes id='sRLhY'>

      <bdo id='sRLhY'></bdo><ul id='sRLhY'></ul>
    <tfoot id='sRLhY'></tfoot>
  3. <i id='sRLhY'><tr id='sRLhY'><dt id='sRLhY'><q id='sRLhY'><span id='sRLhY'><b id='sRLhY'><form id='sRLhY'><ins id='sRLhY'></ins><ul id='sRLhY'></ul><sub id='sRLhY'></sub></form><legend id='sRLhY'></legend><bdo id='sRLhY'><pre id='sRLhY'><center id='sRLhY'></center></pre></bdo></b><th id='sRLhY'></th></span></q></dt></tr></i><div id='sRLhY'><tfoot id='sRLhY'></tfoot><dl id='sRLhY'><fieldset id='sRLhY'></fieldset></dl></div>

      SQLite 表约束 - 在多列上唯一

      时间:2023-10-10

        <tfoot id='TZCUd'></tfoot>

      1. <i id='TZCUd'><tr id='TZCUd'><dt id='TZCUd'><q id='TZCUd'><span id='TZCUd'><b id='TZCUd'><form id='TZCUd'><ins id='TZCUd'></ins><ul id='TZCUd'></ul><sub id='TZCUd'></sub></form><legend id='TZCUd'></legend><bdo id='TZCUd'><pre id='TZCUd'><center id='TZCUd'></center></pre></bdo></b><th id='TZCUd'></th></span></q></dt></tr></i><div id='TZCUd'><tfoot id='TZCUd'></tfoot><dl id='TZCUd'><fieldset id='TZCUd'></fieldset></dl></div>
            <tbody id='TZCUd'></tbody>
          <legend id='TZCUd'><style id='TZCUd'><dir id='TZCUd'><q id='TZCUd'></q></dir></style></legend>
        • <small id='TZCUd'></small><noframes id='TZCUd'>

                <bdo id='TZCUd'></bdo><ul id='TZCUd'></ul>

                本文介绍了SQLite 表约束 - 在多列上唯一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我可以在 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 表约束 - 在多列上唯一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何从sqlite查询中获取dict? 下一篇:DATETIME 值如何在 SQLite 中工作?

                相关文章

                    <tfoot id='X4ciP'></tfoot>
                      <bdo id='X4ciP'></bdo><ul id='X4ciP'></ul>
                  1. <legend id='X4ciP'><style id='X4ciP'><dir id='X4ciP'><q id='X4ciP'></q></dir></style></legend>
                    <i id='X4ciP'><tr id='X4ciP'><dt id='X4ciP'><q id='X4ciP'><span id='X4ciP'><b id='X4ciP'><form id='X4ciP'><ins id='X4ciP'></ins><ul id='X4ciP'></ul><sub id='X4ciP'></sub></form><legend id='X4ciP'></legend><bdo id='X4ciP'><pre id='X4ciP'><center id='X4ciP'></center></pre></bdo></b><th id='X4ciP'></th></span></q></dt></tr></i><div id='X4ciP'><tfoot id='X4ciP'></tfoot><dl id='X4ciP'><fieldset id='X4ciP'></fieldset></dl></div>

                    <small id='X4ciP'></small><noframes id='X4ciP'>