当前位置:网站首页>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;
边栏推荐
- 二叉树专题--洛谷 P1229 遍历问题(乘法原理 已知前、后序遍历求中序遍历个数)
- 二叉树专题--AcWing 18. 重建二叉树(利用前、中序遍历,构建二叉树)
- Luogu p1892 [boi2003] Gang (and search for variant anti set)
- [play with FPGA learning 4 in simple terms ----- talk about state machine design]
- K-d tree and octree of PCL
- Luogu p4281 [ahoi2008] emergency gathering / gathering (tree doubling LCA)
- MySQL lethal serial question 4 -- are you familiar with MySQL logs?
- [ark UI] implementation of the startup page of harmonios ETS
- The URL in the RTSP setup header of the axis device cannot take a parameter
- [AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?
猜你喜欢
Hdu1234 door opener and door closer (water question)
Shell programming 01_ Shell foundation
HDU1228 A + B(map映射)
二叉树专题--洛谷 P1229 遍历问题(乘法原理 已知前、后序遍历求中序遍历个数)
From Read and save in bag file Jpg pictures and PCD point cloud
2022 love analysis · panoramic report of digital manufacturers of state-owned enterprises
What are the software product management systems? Inventory of 12 best product management tools
QT learning diary 8 - resource file addition
三.芯片启动和时钟系统
The first white paper on agile practice in Chinese enterprises was released | complete download is attached
随机推荐
How does the whole network display IP ownership?
V2x SIM dataset (Shanghai Jiaotong University & New York University)
MongoDB 学习整理(条件操作符,$type 操作符,limit()方法,skip() 方法 和 sort() 方法)
洛谷 P5536 【XR-3】核心城市(贪心 + 树形 dp 寻找树的中心)
Jenkins安装
Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)
实验电镜距离测量之Matlab处理
一招快速实现自定义快应用titlebar
最详细MySql安装教程
Matlab processing of distance measurement of experimental electron microscope
二叉树专题--AcWing 3540. 二叉搜索树建树(实用板子 构建二叉搜索树 并输出前、中、后序遍历)
二叉树专题--AcWing 47. 二叉树中和为某一值的路径(前序遍历)
php中self和static在方法中的区别
主键策略问题
[play with FPGA learning 5 in simple terms ----- reset design]
Point cloud projection picture
JSP webshell free -- the basis of JSP
Hdu1228 a + B (map mapping)
二叉树专题--AcWing 1497. 树的遍历(利用后、中序遍历,构建二叉树)
Implement custom drawer component in quick application