<tfoot id='TmIFx'></tfoot>

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

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

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

        <bdo id='TmIFx'></bdo><ul id='TmIFx'></ul>
    1. 如何重命名 SQLite 数据库表中的列?

      时间:2023-06-25

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

                  <tbody id='zMjAF'></tbody>

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

                <legend id='zMjAF'><style id='zMjAF'><dir id='zMjAF'><q id='zMjAF'></q></dir></style></legend>
                本文介绍了如何重命名 SQLite 数据库表中的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我需要重命名 SQLite 数据库中某些表中的几列.我知道一个 图片来源:https://www.sqlite.org/images/syntax/alter-table-stmt.gif

                示例:

                CREATE TABLE tab AS SELECT 1 AS c;选择 * 从选项卡;ALTER TABLE 选项卡将 COLUMN c 重命名为 c_new;选择 * 从选项卡;

                db-fiddle.com 演示

                <小时>

                安卓支持

                在撰写本文时,Android 的 API 27 正在使用 SQLite 包3.19 版.

                基于 Android 正在使用的当前版本以及此更新将在 SQLite 3.25.0 版中推出,我想说您需要等待一段时间(大约 API 33)才能将此支持添加到 Android.

                而且,即便如此,如果您需要支持 API 33 之前的任何版本,您将无法使用它.

                I would need to rename a few columns in some tables in a SQLite database. I know that a similar question has been asked on stackoverflow previously, but it was for SQL in general, and the case of SQLite was not mentioned.

                From the SQLite documentation for ALTER TABLE, I gather that it's not possible to do such a thing "easily" (i.e. a single ALTER TABLE statement).

                I was wondering someone knew of a generic SQL way of doing such a thing with SQLite.

                解决方案

                This was just fixed with 2018-09-15 (3.25.0)

                Enhancements the ALTER TABLE command:

                • Add support for renaming columns within a table using ALTER TABLE table RENAME COLUMN oldname TO newname.
                • Fix table rename feature so that it also updates references to the renamed table in triggers and views.

                You can find the new syntax documented under ALTER TABLE

                The RENAME COLUMN TO syntax changes the column-name of table table-name into new-column-name. The column name is changed both within the table definition itself and also within all indexes, triggers, and views that reference the column. If the column name change would result in a semantic ambiguity in a trigger or view, then the RENAME COLUMN fails with an error and no changes are applied.

                Image source: https://www.sqlite.org/images/syntax/alter-table-stmt.gif

                Example:

                CREATE TABLE tab AS SELECT 1 AS c;
                
                SELECT * FROM tab;
                
                ALTER TABLE tab RENAME COLUMN c to c_new;
                
                SELECT * FROM tab;
                

                db-fiddle.com demo


                Android Support

                As of writing, Android's API 27 is using SQLite package version 3.19.

                Based on the current version that Android is using and that this update is coming in version 3.25.0 of SQLite, I would say you have bit of a wait (approximately API 33) before support for this is added to Android.

                And, even then, if you need to support any versions older than the API 33, you will not be able to use this.

                这篇关于如何重命名 SQLite 数据库表中的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:向现有列添加标识 下一篇:改变列:null 到 not null

                相关文章

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

                    <small id='6iR2P'></small><noframes id='6iR2P'>

                    <legend id='6iR2P'><style id='6iR2P'><dir id='6iR2P'><q id='6iR2P'></q></dir></style></legend>