银行数据库

对一个表添加一个列后,以前的记录在page页内的存储方式?

假设新建一个表 create test1 (c1 int)
插入三个记录,值分别为1,2,3。简单假设在page上的0~3字节保存了记录1,4~7字节保持记录2,8~11字节保存记录3.
之后增加一列c2:alter table add column c2 int
这样每条记录占用的量应该由4字节增加到8字节,我想问一下,在增加一列后,以前的记录是自动reorg扩到现在的大小,比如说第一个记录从占有0~3字节变为占0~7字节,还是在先前的每条记录处定义一个指针,在这个page的空闲处存放新添加的列?
参与10

9同行回答

haoqingyunhaoqingyun数据库运维工程师CMBC
回答得好!显示全部
回答得好!收起
银行 · 2010-10-22
浏览350
cedarbirdcedarbird工程师CDI
类似的内容好象在哪里读过的...显示全部
类似的内容好象在哪里读过的...收起
IT分销/经销 · 2010-10-22
浏览361
看到最后发现了!显示全部
看到最后发现了!收起
2010-10-22
浏览325
请大牛解释一下是不是会发生pctfree预防的事情呢?这么做是不是会使得以前的表空间数据重新排列?显示全部
请大牛解释一下是不是会发生pctfree预防的事情呢?这么做是不是会使得以前的表空间数据重新排列?收起
2010-10-22
浏览342
dikarsdikars数据库管理员DGLCAMEL
okokok收起
互联网服务 · 2010-10-22
浏览363
mdkiimdkii软件开发工程师bocn
很好,学习显示全部
很好,学习收起
银行 · 2010-10-22
浏览342
limin19821limin19821系统工程师乐酷天
When a new column is added to an existing table, only the table description in the system catalog is ...stephensun123 发表于 2010-10-21 17:25 解释的真不赖! 顶一个!显示全部
When a new column is added to an existing table, only the table description in the system catalog is ...
stephensun123 发表于 2010-10-21 17:25

解释的真不赖! 顶一个!收起
IT分销/经销 · 2010-10-21
浏览336
ysgiftysgift数据库管理员招商银行
When a new column is added to an existing table, only the table description in the system catalog is ...stephensun123 发表于 2010-10-21 17:25 是否可以分享一下出处?显示全部
When a new column is added to an existing table, only the table description in the system catalog is ...
stephensun123 发表于 2010-10-21 17:25


是否可以分享一下出处?收起
银行 · 2010-10-21
浏览341
stephensun123stephensun123软件开发工程师SAP China
When a new column is added to an existing table, only the table description in the system catalog is modified, so access time to the table is not affected immediately. Existing records are not physically altered until they are modified using an UPDAT...显示全部
When a new column is added to an existing table, only the table description in the system catalog is modified, so access time to the table is not affected immediately. Existing records are not physically altered until they are modified using an UPDATE statement. When retrieving an existing row from the table, a null or default value is provided for the new column, depending on how the new column was defined. Columns that are added after a table is created cannot be defined as NOT NULL: they must be defined as either NOT NULL WITH DEFAULT or as nullable.

So because the existing rows are not changed at the time of the ALTER, they are shorter than any new rows. They will stay like this until they are updated or the table is REORGed. When the update happened, if no enough space around the record, there will be a page reorg or even a overflow.

So reorg the table after that is a good idea.收起
互联网服务 · 2010-10-21
浏览327

提问者

ysgift
数据库管理员招商银行
擅长领域: 系统运维智能化运维

相关问题

相关资料

相关文章

问题状态

  • 发布时间:2010-10-21
  • 关注会员:1 人
  • 问题浏览:3587
  • 最近回答:2010-10-22
  • X社区推广