当前位置:网站首页>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;
边栏推荐
- 二.Stm32f407芯片GPIO编程,寄存器操作,库函数操作和位段操作
- Resources读取2d纹理 转换为png格式
- 高德根据轨迹画线
- 快应用中实现自定义抽屉组件
- Use Huawei performance management service to configure the sampling rate on demand
- QT学习日记8——资源文件添加
- TIPC addressing 2
- Is the account above changtou school safe?
- Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)
- tqdm的多行显示与单行显示
猜你喜欢
QT学习日记8——资源文件添加
华为AppLinking中统一链接的创建和使用
如何用list组件实现tabbar标题栏
二叉树专题--AcWing 47. 二叉树中和为某一值的路径(前序遍历)
Tick Data and Resampling
Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)
[in simple terms, play with FPGA learning 3 ----- basic grammar]
二叉树专题--AcWing 3384. 二叉树遍历(已知先序遍历 边建树 边输出中序遍历)
Flink two Open, implement Batch Lookup join (attached source)
Iii. Système de démarrage et d'horloge à puce
随机推荐
TIPC协议
PHP tea sales and shopping online store
Luogu p5536 [xr-3] core city (greed + tree DP looking for the center of the tree)
洛谷 P5536 【XR-3】核心城市(贪心 + 树形 dp 寻找树的中心)
Appgallery connect scenario development practice - image storage and sharing
QT learning diary 7 - qmainwindow
Leetcode 182 Find duplicate email (2022.07.01)
I STM32 development environment, keil5/mdk5.14 installation tutorial (with download link)
Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)
sqlite 修改列类型
Win11 arm system configuration Net core environment variable
flink二開,實現了個 batch lookup join(附源碼)
How to transfer event objects and user-defined parameters simultaneously in Huawei express applications
[AI application] Hikvision ivms-4200 software installation
Special topic of binary tree -- acwing 1497 Traversal of the tree (use post and mid order traversal to build a binary tree)
Jenkins安装
Array splitting (regular thinking
最详细MySql安装教程
启牛商学院给的股票账户安全吗?能开户吗?
TIPC Cluster5