数据库
首页 > 数据库> > Oracle中复制注释到新表中去

Oracle中复制注释到新表中去

作者:互联网

declare
  v_comment varchar2(100);
  v_stmt varchar2(4000);
  v_orig_table varchar2(100) :='ORIGINAL_TABLE';
  v_new_table varchar2(100) :='MYTABLE';
begin
  for c in (select column_name
              from user_tab_columns c
             where table_name=v_orig_table
               and exists(select 1 
                            from user_tab_columns
                            where table_name=v_new_table
                              and column_name=c.column_name)) loop
    select comments 
    into v_comment
    from user_col_comments 
    where table_name= v_orig_table
    and column_name=c.column_name;

    v_stmt:='comment on column '||v_new_table||'.'||c.column_name||' IS '''||v_comment||'''';

    execute  immediate v_stmt;
  end loop;

end;

标签:comment,name,新表中,column,注释,varchar2,Oracle,table,select
来源: https://www.cnblogs.com/asashiharuka/p/15048335.html