Oracle数据库对表字段的操作命令

在二次开发一个工程时,经常会遇到对库表的字段的操作,以下是部分常用到的命令:

--添加表(TDM_WELD)字段

例子1:
ALTER TABLE TDM_WELD
ADD (IS_AUT NUMBER(1) DEFAULT 0,
IS_EMBALMED NUMBER(1)DEFAULT 0 );

例子二:

alter table test1
add (name varchar2(30) default '贵姓赵' not null,
age integer default 22 not null,
has_money number(9,2));

DEFAULT 表示默认添加的值
--添加注释
comment on column TDM_WELD.Is_Aut is '全自动超声波检测 0:未检测;1:已检测';
comment on column TDM_WELD.Is_Embalmed is '防腐状态 0:未防腐;1:已防腐';

--清空列(用第一个就行)
update TDM_WELD t set t.IS_EMBALMED=null

update dxxx d set d.tydm=replace(tydm,'?','') 

update dxxx d set d.tydm=replace(tydm,'?',null) 

--修改
alter table TDM_WELD
modify (IS_AUT NUMBER(1) default 0);

--删除列
alter table TDM_WELD drop column IS_AUT;

猜你喜欢

转载自www.cnblogs.com/Williamwen/p/9173628.html