db2修改已经有数据的列名

--修改列名或者列类型,由原类型到其他类型,修改类型有6步,只修改列名则只须4,5,6

--修改start_date的列名或者列类型
--1.增加临时列
ALTER TABLE   <table name>  add  temp_column  timestamp ;
--2.更新临时列的数据为想要的样子
update <table name>  set   temp_column = timestamp(char(start_date) || ' 00:00:00') ;
--3.删除原列
ALTER TABLE   <table name>   DROP COLUMN start_date ;
--.重组表
REORG TABLE   <table name> ;
--4.增加新列(原列的修改形态,类型或者列名)
ALTER TABLE   <table name>   add   start_date  timestamp ;
--5.把临时列的数据更新到新列
update <table name>  set   start_date = temp_column ;
--6.删除临时列
ALTER TABLE   <table name>   DROP COLUMN  temp_column ;
--000.重组表(完成)
REORG TABLE   <table name> ;

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值