在sqlite3中修改列的类型 [英] Modify a Column's Type in sqlite3

查看:563
本文介绍了在sqlite3中修改列的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对SQLite 3还是很陌生,刚才我必须在已有的表中添加一列。我这样做的方法是: ALTER TABLE thetable ADD COLUMN类别;

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 Modify Column

这篇关于在sqlite3中修改列的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆