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 表约束 - 在多列上唯一

      SQLite table constraint - unique on multiple columns(SQLite 表约束 - 在多列上唯一)

        <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 loop statements?(SQLite 循环语句?)
                Can I use parameters for the table name in sqlite3?(我可以在 sqlite3 中使用表名的参数吗?)
                SQL - Inserting a row and returning primary key(SQL - 插入一行并返回主键)
                How to get the number of rows of the selected result from sqlite3?(如何从sqlite3中获取所选结果的行数?)
                Python : How to insert a dictionary to a sqlite database?(Python:如何将字典插入到 sqlite 数据库中?)
                What are the advantages of VistaDB(VistaDB有什么优势)

                    <tfoot id='X4ciP'></tfoot>
                      <bdo id='X4ciP'></bdo><ul id='X4ciP'></ul>
                        <tbody id='X4ciP'></tbody>
                      <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'>