sqlite rename column name

前端之家收集整理的这篇文章主要介绍了sqlite rename column name前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Say you have a table and need to rename "colb" to "col_b":

First you rename the old table:

ALTER TABLE orig_table_name RENAME TO tmp_table_name;

Then create the new table,based on the old table but with the updated column name:

CREATE TABLE orig_table_name ( col_a INT , col_b INT );

Then copy the contents across from the original table.

INSERT INTO orig_table_name(col_a, col_b) SELECT col_a, colb FROM tmp_table_name;

Lastly,drop the old table.

DROP TABLE tmp_table_name;

Wrapping all this in aBEGIN TRANSACTION;andCOMMIT;is also probably a good idea.

原文链接:https://www.f2er.com/sqlite/201003.html

猜你在找的Sqlite相关文章