当前位置:网站首页>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;
边栏推荐
- Leetcode 182 Find duplicate email (2022.07.01)
- Special topic of binary tree -- acwing 19 The next node of the binary tree (find the successor of the node in the tree)
- 6种单例模式的实现方式
- 【深入浅出玩转FPGA学习4----漫谈状态机设计】
- TIPC介绍1
- Learn open62541 -- [66] UA_ Generation method of string
- 从.bag文件中读取并保存.jpg图片和.pcd点云
- [play with FPGA learning 4 in simple terms ----- talk about state machine design]
- 【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
- 快应用中实现自定义抽屉组件
猜你喜欢

Uncover the secrets of Huawei application market application statistics

JSP webshell free -- the basis of JSP

618 what is the secret of dominating the list again? Nike's latest financial report gives the answer

【深入浅出玩转FPGA学习2----设计技巧(基本语法)】

I STM32 development environment, keil5/mdk5.14 installation tutorial (with download link)
![[applinking practical case] share in app pictures through applinking](/img/12/5616f1fa55387b81e25e55a98022b9.png)
[applinking practical case] share in app pictures through applinking

【深入浅出玩转FPGA学习4----漫谈状态机设计】

Flink two Open, implement Batch Lookup join (attached source)

III Chip startup and clock system

Shell programming 01_ Shell foundation
随机推荐
二叉树专题--洛谷 P1229 遍历问题(乘法原理 已知前、后序遍历求中序遍历个数)
二叉树专题--AcWing 19. 二叉树的下一个节点(找树中节点的后继)
QT learning diary 7 - qmainwindow
二叉树专题--洛谷 P3884 [JLOI2009]二叉树问题(dfs求二叉树深度 bfs求二叉树宽度 dijkstra求最短路)
Flink two Open, implement Batch Lookup join (attached source)
Implementation of six singleton modes
二叉树专题--【深基16.例7】普通二叉树(简化版)(multiset 求前驱 后继 哨兵法)
主键策略问题
Special topic of binary tree -- acwing 47 Path with a certain value in binary tree (preorder traversal)
The URL in the RTSP setup header of the axis device cannot take a parameter
最详细MySql安装教程
QT learning diary 8 - resource file addition
金山云——2023届暑期实习
Indexer in C #
How does the whole network display IP ownership?
HDU1228 A + B(map映射)
2022爱分析· 国央企数字化厂商全景报告
Logu p3398 hamster looks for sugar (double LCA on the tree to judge whether the two paths in the tree intersect)
TIPC Service and Topology Tracking4
static 函数中的静态变量