首页 > 其他 > 详细

forname

时间:2017-09-19 22:27:09      阅读:267      评论:0      收藏:0      [点我收藏+]
 begin
  for mytable in (
  SELECT
A.table_name table_name    --表名
  ,b.COLUMN_ID COLUMN_ID   --字段index
 ,b.column_name column_name --字段名
      ,b.data_type data_type     --字段类型
      ,b.data_length             --字段长度
      ,a.comments comments       --字段注释     
   
FROM user_col_comments a
    ,all_tab_columns b
WHERE a.table_name = b.table_name and b.table_name not in (select VIEW_NAME from  user_views) and 
    b.COLUMN_ID = 1 and data_type=RAW--查询条件
    group by b.column_name,b.data_type,b.DATA_LENGTH,a.comments,    a.table_name,b.COLUMN_ID
    ) loop
    dbms_output.put_line(alter table "||mytable.table_name || " ||  add constraint PK_|| mytable.table_name|| primary key ("||mytable.column_name||" );     );
  end loop;
end;


declare
ret sys_refcursor; l_curid NUMBER; l_col_cnt NUMBER; l_desc_tab DBMS_SQL.DESC_TAB; begin DBMS_OUTPUT.ENABLE(buffer_size => null); "usp_FormLastInfo"(2,4,S722032,ret); l_curid := DBMS_SQL.to_cursor_number(ret); --DBMS_OUTPUT.PUT_LINE(l_curid); DBMS_SQL.DESCRIBE_COLUMNS(l_curid, l_col_cnt, l_desc_tab); --DBMS_OUTPUT.PUT_LINE(l_col_cnt); FOR i IN 1 .. l_col_cnt LOOP DBMS_OUTPUT.PUT_LINE(<metadata columnName="||chr(38)||quot;||l_desc_tab(i).col_name||chr(38)||quot;" columnOrdinal="|| to_char(i-1) || " nativeDataType="||to_char( CASE l_desc_tab(i).col_type WHEN 1 THEN Varchar2 WHEN 2 THEN Number WHEN 180 THEN Timestamp WHEN 23 THEN Raw ELSE None END) ||" providerType="||to_char( CASE l_desc_tab(i).col_type WHEN 1 THEN Varchar2 WHEN 2 THEN Int32 WHEN 180 THEN TimeStamp WHEN 23 THEN Raw ELSE None END)||" allowDBNull="true" />); --DBMS_OUTPUT.PUT_LINE(l_desc_tab(i).col_name); --DBMS_OUTPUT.PUT_LINE(l_desc_tab(i).col_type); END LOOP; end;

 

forname

原文:http://www.cnblogs.com/zhutiehan/p/7554133.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!