Oracle 列出指定表的所有字段

DEMO

 

  /*
  列出指定表的所有字段, 使用时将 SYS_TABLE 换成具体表名即可[Oracle 10g,11g下运行通过]
  */
  
  
  declare
    cursor c is
      select a.COLUMN_NAME || ' '
        from all_tab_columns a
       where a.TABLE_NAME = 'CUX_PO_LOCATION_DATA';
  
    col  user_tab_columns.COLUMN_NAME%type;
    cols varchar2(4000);
  begin
    open c;
    loop
      fetch c
        into col;
      exit when c%notfound;
      if cols is null then
        cols := col;
      else
        cols := cols || '--' || col;
      end if;
    
    end loop;
    close c;
  
    dbms_output.put_line(cols);
  end;

 


   

posted @ 2024-04-07 14:52  Iven_lin  阅读(83)  评论(0)    收藏  举报