注释comment 、约束constraints插入数据EXCEPTION处理

 
1、给某列加注释
comment on column emp.ename is '员工姓名';
select comments,COLUMN_NAME from user_col_comments where table_name='EMP';

 


2、约束异常EXCEPTION实验
 create table test(c1 number,c2 char(10));


 insert into test values(1,'aaa');


 commit;


 alter table test add constraints u_name unique(c2);      增加Unique约束


 insert into test(1,'aaa');

 

 insert into test values(2,'aaa');                                       插入该数据会提示违反约束


 alter table test disable constraints u_name;                   先将该约束禁用

 

 insert into test values(2,'aaa');                                       可以插入该数据

 

 至RDBMS/ADMIN/utlexcpt.sql中调用建表exceptions脚本

 create table exceptions(row_id rowid,
                 owner varchar2(30),
                 table_name varchar2(30),
          constraint varchar2(30));


 alter table test enable constraint u_name exceptions into exceptions;  将异常的表导入exceptions便插入该数据   


 select ROW_ID from exceptions;


 select rowid,c1,c2 from test where rowid in(select ROW_ID from exceptions);  从异常的表读取rowid 


 update test set c2='bbbb' where rowid='AAAM1CAAEAAAAGlAAB';         找出异常数据修改或删除


 truncate table exceptions; 从异常表删除数据

 

 

 

5月19日实验

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值