varchar field size issue
I have a sqlite3 table. One of the columns is a varchar(12).
The issue:
I开发者_开发问答 am saving a string value that has no length restriction (NSString *). However the backend sql table column is a varchar(12).
Example:
"Hello world, how are you today?" // this is well beyond the size of a varchar(12)
What i am seeing:
- I save this really long string to the table.
- I restart the app.
- I notice that the string value queried from the table is the full string value (it's not truncated to 12 characters as i was expecting).
Question:
Why isn't the string being truncated? Even the next field in the table seems to retain its proper value (there doesn't appear to be any memory overflow).
See the sqlite FAQ. Specifically it states (question 9) that the length of a VARCHAR is ignored and you can always put up to 500 characters in one.
精彩评论