Home > Database > Mysql Tutorial > 列出指定表的所有字段

列出指定表的所有字段

WBOY
Release: 2016-06-07 14:56:26
Original
1123 people have browsed it

晚上时,师弟yangyu说他有一个表,里面有90多个字段,需要把所有字段都列出来,如果手动一个一个复制出来的话,太麻烦了,就写了个小脚本. 无 /* 列出指定表的所有字段, 使用时将 SYS_TABLE 换成具体表名即可[Oracle 10g下运行通过]*/declare cursor c is select a

晚上时,师弟yangyu说他有一个表,里面有90多个字段,需要把所有字段都列出来,如果手动一个一个复制出来的话,太麻烦了,就写了个小脚本.

/*
 列出指定表的所有字段, 使用时将 SYS_TABLE 换成具体表名即可[Oracle 10g下运行通过]
*/
declare
  cursor c is 
  select a.COLUMN_NAME||' ' from user_tab_columns a
  where a.TABLE_NAME = 'SYS_TABLE';
  
  col user_tab_columns.COLUMN_NAME%type;
  cols varchar2(4000);
begin
  open c;
  loop
    fetch c into col;
    exit when c%notfound;
    cols := cols || col;
  end loop;
  close c;
  
  dbms_output.put_line(cols);
end;
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template