如何更改sqlite列(iPhone)? [英] How to ALTER sqlite column (iPhone)?

查看:38
本文介绍了如何更改sqlite列(iPhone)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于iPhone,由于sqlite3不支持对列进行ALTER操作,如何更改需要保留其数据的表上列的数据类型?

For the iPhone, since sqlite3 doesn't support ALTER for a column, how do I change the data type of a column on a table that needs to preserve its data?

推荐答案

SQLite使用清单(动态)类型.列类型仅作为参考,因此不需要更改列数据类型.列相似性仅用于提供与静态类型数据库的兼容性.

SQLite uses Manifest (Dynamic) typing. The column types are a guide only and so Altering the column data type is not necessary. Column Affinity is used just to provide compatibility with statically typed databases.

SQLite文档:

SQLite使用动态类型.确实不强制执行数据类型约束.任何数据可以插入到任何列中.您可以放置​​任意长度的字符串到整数列中,浮点数布尔列中的数字或日期在字符列中.您的数据类型分配给CREATE TABLE中的一列命令不限制什么数据可以放在该列中...

SQLite uses dynamic typing. It does not enforce data type constraints. Any data can be inserted into any column. You can put arbitrary length strings into integer columns, floating point numbers in boolean columns, or dates in character columns. The datatype you assign to a column in the CREATE TABLE command does not restrict what data can be put into that column...

SQLite确实使用了声明的类型专栏提示您更喜欢该格式的值.因此对于例如,如果列是类型整数,您尝试插入一个字符串进入该列,SQLite将尝试将字符串转换为整数.如果可以,则插入整数反而.如果没有,它将插入字符串

SQLite does use the declared type of a column as a hint that you prefer values in that format. So, for example, if a column is of type INTEGER and you try to insert a string into that column, SQLite will attempt to convert the string into an integer. If it can, it inserts the integer instead. If not, it inserts the string

他们继续说这不是错误,而是功能.如果您的应用程序有问题,我想SQlite可能不是您的最佳选择.

They go on to say that this is not a bug but a feature. If it is a problem for your application I guess SQlite may not be the best choice for you.

这篇关于如何更改sqlite列(iPhone)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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