当前位置:网站首页>sqlite 修改列类型
sqlite 修改列类型
2022-07-02 07:41:00 【炎黄子孙__】
简介
sqlite 无法直接修改列类型,所以需要建立临时表,先把数据拷贝到临时表中,然后再创建新表,然后再将临时表的数据拷贝回来。
示例
-- 创建临时表 sqlitestudio_temp_table,并与表 learn_info 的数据和结构一致
CREATE TABLE sqlitestudio_temp_table AS SELECT * FROM learn_info;
-- 删除原来的表
DROP TABLE learn_info;
-- 新建表,该新建指令已经修改了列的数据类型
CREATE TABLE learn_info (
id INTEGER PRIMARY KEY AUTOINCREMENT,
type INT,
thought TEXT,
book INT,
chapter INT,
section INT,
number TEXT,
repeat INT DEFAULT 1,
failed_repeat INT DEFAULT 0,
star INT,
comment TEXT,
span INT,
update_time DATE DEFAULT (datetime('now', 'localtime') ),
version INT,
deleted INT
);
-- 将临时表的数据插入到新表里面,如果修改后的字段无法插入,可以把那一列给去掉
INSERT INTO learn_info (
id,
type,
thought,
book,
chapter,
section,
number,
repeat,
failed_repeat,
star,
comment,
span,
update_time,
version,
deleted
)
SELECT id,
type,
thought,
book,
chapter,
section,
number,
repeat,
failed_repeat,
star,
comment,
span,
update_time,
version,
deleted
FROM sqlitestudio_temp_table;
-- 删除临时表
DROP TABLE sqlitestudio_temp_table;
边栏推荐
猜你喜欢

JSP webshell free -- webshell free

How to implement tabbar title bar with list component

LabVIEW为什么浮点数会丢失精度
![[play with FPGA learning 5 in simple terms ----- reset design]](/img/57/816a59787259dc32b52897c069e1a6.png)
[play with FPGA learning 5 in simple terms ----- reset design]

Flick two open, realized a batch lookup join (with source code)

Jsp webshell Free from killing - The Foundation of JSP

二叉树专题--AcWing 18. 重建二叉树(利用前、中序遍历,构建二叉树)

二叉树专题--AcWing 19. 二叉树的下一个节点(找树中节点的后继)

华为快应用中如何实现同时传递事件对象和自定义参数

一招快速实现自定义快应用titlebar
随机推荐
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
二叉树专题--AcWing 1589. 构建二叉搜索树
JSP webshell free -- webshell free
AppGallery Connect场景化开发实战—图片存储分享
Luogu p5536 [xr-3] core city (greed + tree DP looking for the center of the tree)
使用华为性能管理服务,按需配置采样率
Set the playback speed during the playback of UOB equipment
Flick two open, realized a batch lookup join (with source code)
The most detailed MySQL installation tutorial
如何用list组件实现tabbar标题栏
V2X-Sim数据集(上海交大&纽约大学)
flink二開,實現了個 batch lookup join(附源碼)
PCL extracts a subset from a point cloud
Why does LabVIEW lose precision in floating point numbers
TIPC协议
二叉树专题--AcWing 3540. 二叉搜索树建树(实用板子 构建二叉搜索树 并输出前、中、后序遍历)
2022-06-17
Disassembling Meitu SaaS: driving the plane to change the engine
全网显示 IP 归属地,是怎么实现的?
Uncover the secrets of Huawei application market application statistics