当前位置:网站首页>达梦数据库大表添加字段
达梦数据库大表添加字段
2022-08-05 07:29:00 【Asky】
一个1000多万记录的大表,尝试添加字段,语句如下:
alter table "HXL"."TB_OBJECTS" add column(NAME varchar(30)); ##执行很久
该语句执行很久,期间尝试开启另外的一个会话写入数据
insert into tb_objects(owner) values('TT'); ##一直等待
发现无法写入,一直在等待,请问下大表加字段怎么做呢?不能影响到业务使用
采纳答案1:
可以考虑设置参数alter_table_opt,设置为1,添加列采用查询插入法,可能导致rowid变化;ALTER_TABLE_OPT 为 2 时,系统开启快速加列功能,对于没有默认值或者默认值为 NULL 的新列,系统内部会标记为附加列,能够达到瞬间加列的效果, 此时 ROWID 不会改变, 若有默认值且默认值不为 NULL,则仍旧采取查询插入实现。如果设置成3,系统开启快速加列模式,允许指定新增列的默认值,系统会为该列设置附加列标记,查询表中已存在的数据时,会自动为记录设置追加列默认值,rowid不变。
其他答案1:
可以考虑设置参数alter_table_opt,设置为1,添加列采用查询插入法,可能导致rowid变化;ALTER_TABLE_OPT 为 2 时,系统开启快速加列功能,对于没有默认值或者默认值为 NULL 的新列,系统内部会标记为附加列,能够达到瞬间加列的效果, 此时 ROWID 不会改变, 若有默认值且默认值不为 NULL,则仍旧采取查询插入实现。如果设置成3,系统开启快速加列模式,允许指定新增列的默认值,系统会为该列设置附加列标记,查询表中已存在的数据时,会自动为记录设置追加列默认值,rowid不变。
其他答案2:
感谢,试了下,设置成3,添加带默认值字段秒级完成
ALTER_TABLE_OPT=3
[执行语句1]:
alter table HXL.TB_OBJECTS add column(NAME varchar(30) default 'AA' not null);
执行成功, 执行耗时60毫秒. 执行号:700
边栏推荐
- 任务流调度工具AirFlow,,220804,,
- Mysql 死锁和死锁的解决方案
- 4520. 质数
- GAN generates anime avatar Pytorch
- 唤醒手腕 - 微信小程序、QQ小程序、抖音小程序学习笔记(更新中)
- C# FileSystemWatcher
- After the firewall iptable rule is enabled, the system network becomes slow
- 2022 crane driver (limited bridge crane) exam question bank and simulation test
- 小本创业者的致胜法宝!
- Redis数据库学习
猜你喜欢

Algorithm Supplements Fifteen Complementary Linked List Related Interview Questions

MySQL:连接查询 | 内连接,外连接

protobuf is compiled against the associated .proto file

Summary of Text Characterization Methods

In the anaconda Promat interface, import torch is passed, and the error is reported in the jupyter notebook (only provide ideas and understanding!)

TRACE32——通用寄存器查看与修改

Vulnhub target drone: HA_ NARAK

爬虫从入门到入牢

Shiny02---Shiny exception solution

VXE-Table融合多语言
随机推荐
Takeda Fiscal 2022 First Quarter Results Strong; On Track to Achieve Full-Year Management Guidance
Bluetooth gap protocol
在anaconda Promat界面import torch通过,在jupyter notebook中报错的问题(仅提供思路理解!)
Shiny04---DT和进度条在shiny中的应用
2022 crane driver (limited bridge crane) exam question bank and simulation test
U++ UE4官方文档课后作业
TRACE32——Break
TRACE32——加载符号表信息用于调试
奇怪的Access错误
双向循环带头链表
691. 立方体IV
Use of thread pool (combined with Future/Callable)
window.open 全屏展示
RNote108---显示R程序的运行进度
3555. 二叉树
Hash these knowledge you should also know
Vulnhub靶机:HA_ NARAK
关于MP3文件中找不到TAG标签的问题
图扑软件与华为云共同构建新型智慧工厂
性能提升400倍丨外汇掉期估值计算优化案例