zoukankan      html  css  js  c++  java
  • oracle 将表名和字段名变为大写

    文章目录

    • 前言
    • 一、批量将表名变为大写
    • 二、批量将空间内所有表的所有字段名变成大写
    • 三、将用户空间的所有表名及所有字段变为大写
    • 前言

      当使用powerdesigner创建数据库时要注意大小写。
      注:以下脚本在oracle 10g,11g上正确执行

      一、批量将表名变为大写

       1 begin
       2    for c in (select table_name tn from user_tables where table_name <> upper(table_name)) loop
       3        begin
       4           execute immediate 'alter table "'||c.tn||'" rename to '||c.tn;
       5        exception
       6           when others then
       7              dbms_output.put_line(c.tn||'已存在');
       8        end;
       9    end loop; 
      10 end;
    • 二、批量将空间内所有表的所有字段名变成大写

    •  1 begin
       2   for t in (select table_name tn from user_tables) loop
       3       begin
       4          for c in (select column_name cn from user_tab_columns where table_name=t.tn) loop
       5              begin
       6                 execute immediate 'alter table "'||t.tn||'" rename column "'||c.cn||'" to '||c.cn;
       7              exception
       8                 when others then
       9                    dbms_output.put_line(t.tn||'.'||c.cn||'已经存在');
      10              end;
      11          end loop;
      12       end;
      13   end loop; 
      14 end;

      三、将用户空间的所有表名及所有字段变为大写

    •  1 begin
       2    for t in (select table_name tn from user_tables where table_name <> upper(table_name)) loop
       3        begin
       4           for c in (select column_name cn from user_tab_columns where table_name=t.tn) loop
       5               begin
       6                  execute immediate 'alter table "'||t.tn||'" rename column "'||c.cn||'" to '||c.cn;
       7               exception
       8                  when others then
       9                     dbms_output.put_line(t.tn||'.'||c.cn||'已经存在');
      10               end;
      11           end loop;
      12       
      13           execute immediate 'alter table "'||t.tn||'" rename to '||t.tn;
      14           exception
      15              when others then
      16                 dbms_output.put_line(t.tn||'已存在');
      17        end;
      18    end loop; 
      19 end;
  • 相关阅读:
    行测-民法典
    行测-中心理解
    行测-资料分析
    行测-数量关系
    行测-三视图、截面图、立体拼合
    行测-加强题型
    C# Unity游戏开发——Excel中的数据是如何到游戏中的 (四)2018.4.3更新
    UGUI batch 规则和性能优化
    Unity 绘图性能优化
    Unity UGUI —— 鼠标穿透UI问题(Unity官方的解决方法)
  • 原文地址:https://www.cnblogs.com/joyny/p/14986487.html
Copyright © 2011-2022 走看看