<tfoot id='Jh2EK'></tfoot>
      <bdo id='Jh2EK'></bdo><ul id='Jh2EK'></ul>
  • <small id='Jh2EK'></small><noframes id='Jh2EK'>

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

      1. <legend id='Jh2EK'><style id='Jh2EK'><dir id='Jh2EK'><q id='Jh2EK'></q></dir></style></legend>
      2. 如何从 sqlite (3.6.21) 表中删除约束?

        时间:2023-10-10
            <tbody id='cKDco'></tbody>
          • <bdo id='cKDco'></bdo><ul id='cKDco'></ul>

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

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

                1. 本文介绍了如何从 sqlite (3.6.21) 表中删除约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有下表:

                  CREATE TABLE child( 
                    id INTEGER PRIMARY KEY, 
                    parent_id INTEGER CONSTRAINT parent_id REFERENCES parent(id), 
                    description TEXT);
                  

                  如何删除约束?

                  推荐答案

                  SQLite 不(截至本答案)支持 alter table drop constraint 命令.可以在此处查看允许的语法.您需要创建一个没有约束的新表,传输数据,然后删除旧表.

                  SQLite does not (as of this answer) support the alter table drop constraint command. The allowed syntax can be seen here. You will need to create a new table without a constraint, transfer the data, then delete the old table.

                  我认为类似以下内容应该有效:

                  I think something like the following should work:

                  CREATE TABLE child2 ( 
                      id          INTEGER PRIMARY KEY, 
                      parent_id   INTEGER,
                      description TEXT
                  );
                  INSERT INTO child2 (id, parent_id, description)
                     SELECT id, parent_id, description FROM CHILD;
                  DROP TABLE child;
                  ALTER TABLE child2 RENAME TO child;
                  

                  请注意,insert into 可能会简化为 使用显式列名,但我保留了这种方式,以防您也想更改结构.

                  Note that the insert into could probably be simplified to not use explicit column names but I've left it that way in case you want to change the structure as well.

                  例如,如果您要删除parent_id 列上的约束,那么将其保留在那里的用途很可疑.在这种情况下,您可以将数据传输修改为:

                  For example, if you're removing the constraint on the parent_id column, it's of dubious use to keep it there at all. In that case, you could modify the data transfer to:

                  CREATE TABLE child2 (id INTEGER PRIMARY KEY, description TEXT);
                  INSERT INTO child2 (id, description) SELECT id, description FROM CHILD;
                  

                  这篇关于如何从 sqlite (3.6.21) 表中删除约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何选择每组的前N行? 下一篇:VistaDB有什么优势

                  相关文章

                2. <legend id='lVxd5'><style id='lVxd5'><dir id='lVxd5'><q id='lVxd5'></q></dir></style></legend>

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

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