当前位置:网站首页>SQLite modify column type
SQLite modify column type
2022-07-02 11:13:00 【Chinese descendants__】
brief introduction
sqlite Cannot modify column type directly , So you need to create a temporary table , First copy the data into the temporary table , Then create a new table , Then copy the data of the temporary table back .
Example
-- Create a temporary table sqlitestudio_temp_table, And with the table learn_info The data and structure are consistent
CREATE TABLE sqlitestudio_temp_table AS SELECT * FROM learn_info;
-- Delete the original table
DROP TABLE learn_info;
-- new table , The new instruction has modified the data type of the column
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 the data of the temporary table into the new table , If the modified field cannot be inserted , You can get rid of that column
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;
-- Delete temporary table
DROP TABLE sqlitestudio_temp_table;
边栏推荐
- Gaode draws lines according to the track
- From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang
- PCL eigen introduction and simple use
- K-d tree and octree of PCL
- 三.芯片启动和时钟系统
- Jenkins安装
- How to use ide to automatically sign and debug Hongmeng application
- PKG package manager usage instance in FreeBSD
- 【AI应用】海康威视iVMS-4200软件安装
- Resources读取2d纹理 转换为png格式
猜你喜欢
QT learning diary 8 - resource file addition
快应用中实现自定义抽屉组件
tqdm的多行显示与单行显示
TIPC addressing 2
华为快应用中如何实现同时传递事件对象和自定义参数
JVM之垃圾回收器
Special topic of binary tree -- Logu p1229 traversal problem (the number of traversals in the middle order is calculated when the pre and post order traversals of the multiplication principle are know
Huawei game failed to initialize init with error code 907135000
Iii. Système de démarrage et d'horloge à puce
QT learning diary 7 - qmainwindow
随机推荐
Binary tree topic -- Luogu p3884 [jloi2009] binary tree problem (DFS for binary tree depth BFS for binary tree width Dijkstra for shortest path)
Array splitting (regular thinking
One trick to quickly realize custom application titlebar
【IDEA】使用插件一键逆向生成代码
洛谷 P3398 仓鼠找 sugar(树上倍增 lca 判断树中两条路径是否相交 结论)
TIPC Service and Topology Tracking4
The difference between self and static in PHP in methods
Resources读取2d纹理 转换为png格式
Win11 arm system configuration Net core environment variable
每月1号开始计算当月工作日
Special topic of binary tree -- acwing 1589 Building binary search tree
Static variables in static function
三.芯片啟動和時鐘系統
Special topic of binary tree -- Logu p1229 traversal problem (the number of traversals in the middle order is calculated when the pre and post order traversals of the multiplication principle are know
STM32单片机编程学习
Nodejs+express+mysql simple blog building
计算序列之和
OpenMLDB Meetup No.4 会议纪要
二叉树专题--AcWing 1589. 构建二叉搜索树
Special topic of binary tree -- acwing 19 The next node of the binary tree (find the successor of the node in the tree)