更改varchar2列大小会有什么影响吗?

huangapple go评论62阅读模式
英文:

Will there be any effect if I change the varchar2 column size?

问题

我有一张表,几乎有20列,至少有十亿行。

如果我将其中一列的类型从varchar2(8)更改为varchar2(16)会怎么样?给定列上没有索引、约束或外键。但是我的表中有太多的记录。我将使用下面的脚本进行操作:

ALTER TABLE user MODIFY type VARCHAR2(16);

我已经在我的测试环境中执行了这个操作,但它的记录数没有我的生产环境多。

英文:

I have a table with almost 20 columns and at least one billion rows.

What if I change type of one column from varchar2(8) to varchar2(16)? There is no index, constraint or foreign key on given column. But my table has too many records. I will use below script for the operation:

ALTER TABLE user MODIFY type VARCHAR2(16);

I have done this operation in my test environment but it does not have as many records as my production environment.

答案1

得分: 2

根据我所了解,这将会是立即的。这是一个varchar2列,更改仅在数据字典中进行,表数据不受任何影响。

如果是char的话,是的 - 这将需要时间,因为这样的列包含的数据会在右侧用空格填充到其完整长度,所以您实际上需要扩大列的大小,还要在表上执行更新操作,如果有很多行,那会花费时间。

英文:

As far as I can tell, it'll be instantly. It is a varchar2 column and change is being done only in data dictionary, table data isn't affected at all.

If it were char, then yes - it would take time because such a column contains data right-padded with spaces up to its full length, so you'd actually have to enlarge the column, but also perform update on a table, and that would take time if there are that many rows.

huangapple
  • 本文由 发表于 2023年6月30日 04:58:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76584577.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定