db2中varchar类型长度是多少?

seekmoon 2003-10-24 09:54:36
我创建一个库后,create table,追加一列为varchar(8000),系统包错:
SQL0286N 找不到页大小至少为 "8192"、许可使用授权标识 "DB2ADMIN" 的缺省表空间。 SQLSTATE=42727


我设置改小点,改到4000,也不行,3800倒是可以
请问有什么规律?
怎么了解db2的各种数据类型的最大长度?

如果要让一列长度为8000的varchar,怎么办?
更长一点的呢?
...全文
2802 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Pooling 2003-12-11
  • 打赏
  • 举报
回复
增加一个新的表空间(以及增加相应的缓冲池,缓冲池大小设成能满足要求的即可),然后把表建在新的表空间中。
「已注销」 2003-12-06
  • 打赏
  • 举报
回复
可能是页面限制。DB2支持多种页面大小。
4k页面下最大行长度为4005字节。可能是这个问题!
db2boy 2003-12-06
  • 打赏
  • 举报
回复
varchar不能跨数据页面,如果你的表空间定义的页面的大小是4k,当然varchar不能到8k。
「已注销」 2003-12-06
  • 打赏
  • 举报
回复

Varying-length character string (VARCHAR)
Varying-length character strings are stored in the database using only the amount of space required to store the data. The individual names, in our example, are stored as varying-length strings (VARCHAR) because each persons name has a different length (up to a maximum length of 30 characters). The term CHAR VARYING or CHARACTER VARYING can be used as a synonym for VARCHAR.

If a varying-length character string is updated and the resulting value is larger than the original, the record will be moved to another page in the table. These rows are known as tombstone records or pointer records. Too many of these records can cause significant performance degradation since multiple pages are required to return a single row. The maximum length of a VARCHAR column is 32,672 bytes.

Varying-length long character strings (LONG VARCHAR)
This data type is used to store character data with a varying length. In the past it was used when the VARCHAR was not large enough; however, with the increase of the VARCHAR column to 32,672, the LONG VARCHAR data type may not be used as often.

A VARCHAR column has the restriction that it must fit on one database page. This means that a 4K page would allow a VARCHAR of approximately 4000 characters long, an 8K page would be 8000 and so on up to a 32K page. This means that you must create a tablespace for this table that can accommodate the larger page size, and you must have sufficient space in the row to accommodate this string. A LONG VARCHAR only takes up 24 bytes of space in the row, no matter what the length is. The LONG VARCHAR format will result in the strings being stored in a separate database page, and this will result in longer processing time for these strings since the database will always need to make an extra hop to get to this data.

The maximum length of a LONG VARCHAR column is 32,700.





「已注销」 2003-12-06
  • 打赏
  • 举报
回复
v8中变长字符串VARCHAR的最大长度是 32 672字节。应该没有问题,是不是你的版本不一样?

LONG VARCHAR可以。过去它比VARCHAR要长。

可以试试使用大字符对象CLOB。最大空间是2GB。

希望对你有帮助。

5,889

社区成员

发帖
与我相关
我的任务
社区描述
IBM DB2 是美国IBM公司开发的一套关系型数据库管理系统,它主要的运行环境为UNIX(包括IBM自家的AIX)、Linux、IBM i(旧称OS/400)、z/OS,以及Windows服务器版本
社区管理员
  • DB2
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧