Modify a Column#39;s Type in sqlite3(在 sqlite3 中修改列的类型)
问题描述
我对 SQLite 3 还很陌生,刚才我不得不向我现有的表中添加一列.我开始这样做:ALTER TABLE thetable ADD COLUMN category;.
I'm pretty new to SQLite 3 and just now I had to add a column to an existing table I had. I went about doing that by doing: ALTER TABLE thetable ADD COLUMN category;.
当然,我忘记指定该列的类型.我考虑做的第一件事是删除该列,然后重新添加它.但是,SQLite 似乎没有这样做的简单方法,我不得不备份表并在没有列的情况下重新创建它.
Of course, I forgot to specify that column's type. The first thing I was thinking about doing was dropping that column and then re-adding it. However, it seems that SQLite does not have a simple way of doing this, and I would have had to backup the table and re-create it without the column.
这看起来很乱,我想知道是否只有一种修改/添加列类型的方法.我想是这样,但我的搜索没有产生任何结果,我对 SQLite 不熟悉,我想这是因为我在查询中的措辞不正确.
This seems messy, and I was wondering if there were just a way of modifying/adding a column's type. I would imagine so, but my searching around yielded no results, being new to SQLite, I imagine it was due to my wording being off in the query.
推荐答案
SQLite 不支持删除或修改列,显然.但请记住,SQLite 中的列数据类型也不是严格的.
SQLite doesn't support removing or modifying columns, apparently. But do remember that column data types aren't rigid in SQLite, either.
另见:
- SQLite 修改列
这篇关于在 sqlite3 中修改列的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 sqlite3 中修改列的类型
基础教程推荐
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 无法解决整理冲突 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
