1. 程式人生 > >將oracle 表名,欄位名變為大寫

將oracle 表名,欄位名變為大寫

注:以下指令碼在oracle 10g,11g上正確執行
批量將表名變為大寫
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 '||c.tn;
       exception
          when others then
             dbms_output.put_line(c.tn||'已存在');
       end;
   end loop; 
end;

批量將空間內所有表的所有欄位名變成大寫
begin
  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 '||c.cn;
             exception
                when others then
                   dbms_output.put_line(t.tn||'.'||c.cn||'已經存在');
             end;
         end loop;
      end;
  end loop; 
end;

將使用者空間的所有表名及所有欄位變為大寫
begin
   for t in (select table_name tn from user_tables where table_name <> upper(table_name)) 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 '||c.cn;
              exception
                 when others then
                    dbms_output.put_line(t.tn||'.'||c.cn||'已經存在');
              end;
          end loop;
      
          execute immediate 'alter table "'||t.tn||'" rename to '||t.tn;
          exception
             when others then
                dbms_output.put_line(t.tn||'已存在');
       end;
   end loop; 
end;

相關推薦

oracle 變為大寫

注:以下指令碼在oracle 10g,11g上正確執行 批量將表名變為大寫 begin    for c in (select table_name tn from user_tables where table_name <> upper(table_name)

MyBatis動態傳入引數的解決辦法--用於分--是動態的

MyBatis動態傳入表名,欄位名引數的解決辦法--用於分表--表名是動態的 一直在使用Mybatis這個ORM框架,都是使用mybatis裡的一些常用功能。今天在專案開發中有個業務是需要限制各個使用者對某些表裡的欄位查詢以及某些欄位是否顯示,如某張表的某些欄位不讓使用者查詢到。這種情況下,就需

MyBatis動態傳入引數

問題 Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your

mybatis動態傳入查詢條件進行查詢

mybatis動態傳入表名,欄位名,查詢條件進行查詢 菜鳥一枚,不足之處請多多指出 BaseMapper.xml // BaseMapper.xml <select id="findByFiled" resultType="java.util.Map" statementT

navicat mysql查資料庫中表數量數量(持續更新中)

1.查資料庫中表數量 (紅色標記的是常用到的重要的表結構資訊表) mysql> use information_schema;Database changedmysql> show tables;+-------------------------------

iBatis動態傳入

$和#     public List getProjectCodes(String table, String column, String returnColumn, String value) {     Map map = new HashMap();     map.put("table",

Oracle 查詢庫中所有說明查詢表的資料條數、、中文

查詢所有表名: select t.table_name from user_tables t; 查詢所有欄位名: select t.column_name from user_col_comments t; 查詢指定表的所有欄位名: select t.column_nam

oracle 變為大寫

begin for t in (select table_name tn from user_tables where table_name <> upper(table_name)) loop begin for c in (select column_

ORACLE——在所有中查詢某個字串並輸出

什麼都不想說,直接上乾貨 declare v_Sql varchar2(2000); v_count number; begin for xx in (select t.OWNER, t.TABLE_NAME, t.COLUMN_NAME from

oracle等物件的命名長度限制

原創作品,出自 “深藍的blog” 部落格,歡迎轉載,轉載時請務必註明出處,否則追究版權法律責任。 今天在為某系統資料庫結構整理升級指令碼時,遇到了“命名位元組過長的錯誤”,類似於下面的截圖語句:         由於升級的結構中對於欄位名的命名根據業務進行了修改,出現

postgresql獲取結構註釋、型別及長度和註釋(轉載)

轉載地址:https://blog.csdn.net/weixin_38924323/article/details/80982760 場景描述:navicate 將postgresql表結構匯出到Excel。 1、查詢表名和表註釋 select relna

Sql Server 2008獲取的註釋型別描述等程式碼自動生成必備

SELECT 表名 = case when a.colorder=1 then d.name else ” end, 表說明 = case when a.colorder=1 then isnull(f.value,”) else ” end,

Oracle:、constraint的長度有限制

說明:複製表(只複製結構,源表名:a 新表名:b)     SQL: select * into b from a where 1<>1 feedom.net   說明:拷貝表(拷貝資料,源表名:a 目標表名:b)   中國網管聯盟www_bitscn_com   SQL: insert

查詢某個型別長度及說明,查詢主鍵資訊查詢自增列資訊的儲存過程

create PROCEDURE [dbo].[ziduan] /*  function:查詢某個表的欄位名,欄位型別,長度及欄位說明,並asc排序;查詢主鍵資訊;查詢自增列資訊  */ (@biaoming nvarchar(50) )  ASSET NOCOUNT ON

[]Oracle]查詢表中每隔是否主鍵查詢表、主鍵、資料型別、是否為空和註釋

select    utc.column_name as 欄位名,utc.data_type 資料型別,utc.data_length 最大長度,CASE utc.nullable WHEN 'N' THEN '否' ELSE '是' END 可空,utc.data_defa

sqlite檢視所有及判斷是否存在的方法

sqlite檢視所有表名及欄位名 1.   查詢與判斷表 查詢sqlite中所有表,可用如下sql語句。原理是,sqlite中有一個內建表sqlite_master,這個表中儲存這所有自建表的表名稱等資訊。 select name fromsqlite_master wh

更新一個不確定 java如何實現

StringBuffer sb=new StringBuffer(); sb.append(" update quick_order "); sb.append(" set id=id "); if(StringUtils.isNotBlank(address))

【java學習筆記】MyBatis中當實體類中的屬性中的不一樣時的解決方法

在使用MyBatis開發DAO層時,當實體類中的屬性名和表中的欄位名不一樣時,查詢出來的值為null,此時有3種解決方法 解決方法1                在Mapper.xml對映檔案中,寫SQL語句時起別名 解決

mysql中獲取&的查詢語句

  1:查詢資料庫中所有表名  select table_name   from information_schema.tables   where table_schema='csdb' and table_type='base table';   table_schema:用於限定資料

mysql 獲得指定資料庫所有以及指定的所有

SELECT COLUMN_NAME 列名, DATA_TYPE 欄位型別, COLUMN_COMMENT 欄位註釋 FROM information_schema. COLUMNS WHERE