当前位置:网站首页>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;
边栏推荐
- [play with FPGA learning 2 in simple terms ----- design skills (basic grammar)]
- MySQL lethal serial question 3 -- are you familiar with MySQL locks?
- 金山云——2023届暑期实习
- 二叉树专题--AcWing 3540. 二叉搜索树建树(实用板子 构建二叉搜索树 并输出前、中、后序遍历)
- Matlab processing of distance measurement of experimental electron microscope
- Nodejs+express+mysql simple blog building
- One trick to quickly realize custom application titlebar
- Oracle notes
- TIPC协议
- Regular and common formulas
猜你喜欢

Why does LabVIEW lose precision in floating point numbers

Common methods of JS array

Analysis of hot spots in AI technology industry

OpenMLDB Meetup No.4 会议纪要

三.芯片啟動和時鐘系統

QT学习日记8——资源文件添加

【AGC】构建服务3-认证服务示例

【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决

洛谷 P5536 【XR-3】核心城市(贪心 + 树形 dp 寻找树的中心)

Huawei game failed to initialize init with error code 907135000
随机推荐
二叉树专题--【深基16.例7】普通二叉树(简化版)(multiset 求前驱 后继 哨兵法)
华为AppLinking中统一链接的创建和使用
[in simple terms, play with FPGA learning 3 ----- basic grammar]
The first white paper on agile practice in Chinese enterprises was released | complete download is attached
The most detailed MySQL installation tutorial
Luogu p4281 [ahoi2008] emergency gathering / gathering (tree doubling LCA)
flink二开,实现了个 batch lookup join(附源码)
Hdu1236 ranking (structure Sorting)
PCL eigen introduction and simple use
[applinking practical case] share in app pictures through applinking
6种单例模式的实现方式
I STM32 development environment, keil5/mdk5.14 installation tutorial (with download link)
从.bag文件中读取并保存.jpg图片和.pcd点云
Easyexcel, a concise, fast and memory saving excel processing tool
QT learning diary 7 - qmainwindow
[paid promotion] collection of frequently asked questions, recommended list FAQ
Hdu1234 door opener and door closer (water question)
力扣(LeetCode)182. 查找重复的电子邮箱(2022.07.01)
Flick two open, realized a batch lookup join (with source code)
最详细MySql安装教程