为了账号安全,请及时绑定邮箱和手机立即绑定

oracle sql语句修改表名大小写和字段名大小写

标签:
Java Oracle

-- 修改数据库表名大小写
begin
-- 遍历所有的表名
for c in (select table_name tn from user_tables where table_name <> upper(table_name) ) loop
begin
-- 执行修改
execute immediate 'alter table "'c.tn'" rename to "'upper(c.tn)'"';
exception
when others then
-- 已经存在,输出提示
dbms_output.put_line(c.tn'已存在');
end;
end loop;
end;
begin
-- 启动缓冲
DBMS_OUTPUT.ENABLE (buffer_size=>null) ;
-- 遍历所有表名
for t in (select table_name tn from user_tables) loop
begin
-- 遍历所有列名
for c in (select column_name cn from user_tab_columns where table_name=t.tn) loop
begin
--执行修改语句 注意双引号 与拼接 外单内双
execute immediate 'alter table "'t.tn'" rename column "'c.cn'" to "'upper(c.cn)'"';
-- 异常处理
exception
when others then
dbms_output.put_line(t.tn'.'c.cn'已经存在');
end;
end loop;
end;
end loop;
end;

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
JAVA开发工程师
手记
粉丝
168
获赞与收藏
3550

关注作者,订阅最新文章

阅读免费教程

  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消