SQLite VARCHAR 默认大小 [英] SQLite VARCHAR default size
问题描述
在 SQLite 中,当我说:
In SQLite, when I say:
CREATE TABLE my_table
(
my_column VARCHAR
);
没有指定VARCHAR
的大小,使用的默认大小是多少?
without specifying the size of VARCHAR
, what is the default size that is used?
我似乎无法在 sqlite.org 上找到它,也无法从我的数据库文件中找到它.
I can't seem to find it at sqlite.org or figure out from my database file.
我知道 SQLite 在尝试将 varchar(500)
填充到 varchar(30)
时不会强制执行大小,但是在初始大小规范和什么方面是否存在权衡是最佳做法吗?
I know that SQLite doesn't enforce size when trying to stuff varchar(500)
into varchar(30)
, but are there tradeoffs in initial size specification and what are best practices?
推荐答案
没关系.
SQLite 在声明 VARCHAR
类型时不使用大小.事实上,它几乎也不使用该类型.
SQLite does not use sizes when declaring the VARCHAR
type. In fact, it almost doesn't use the type either.
您可以将 TEXT
存储在 SQLite 的 INT
列中.SQLite 将从不截断 TEXT
列.
You can store TEXT
in an INT
column in SQLite. And SQLite will never truncate a TEXT
column.
这篇关于SQLite VARCHAR 默认大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!