网站首页 > 文章中心 > 其它

oracle查询如何遍历

作者:小编 更新时间:2023-09-29 10:23:54 浏览量:114人看过

oracleo数据库,请问如何遍历rowtype或游标中的各个列?

数据库中有user_tab_columns和user_tables这两个表,你看看,可以解决的你问题.肿么没分

怎么将从oracle数据库表1查询到的字段遍历到checkbox中

表1查出来 后台把数据插到list或者map里传给jsp jsp的foreach遍历显示在action form表单提交可以获取action中数据

oracle中如何查询多张表的数据!

弄个字符串变量,设个游标,用括号里那一串;

然后遍历表名,每找到一个表名,就在字符串变量里拼上一段:=

'select

*

from

'||table_name||';',

然后用EXECUTE

IMMEDIATE执行;

然后读下一个表名,直至遍历完毕.

大致就是这么个意思.

oracle能否遍历数据库里所有表的字段与值

不知道你是写程序用,还是找数据用.写程序的话,一步到位,可能比较复杂!

下面附一点找数据的较笨的方法!看对你有没有用,以用户SCOTT为例:

①dba_tab_columns有某个用户的所以表和列等信息:select table_name,column_name from dba_tab_columns where owner='SCOTT'

set serveroutput on

delete from scott.TCOL;

commit;

declare

cursor my_cursor is

select table_name,column_name from dba_tab_columns where owner='SCOTT' and DATA_TYPE='NUMBER';

begin

open my_cursor;

loop

fetch my_cursor into v_table,v_col;

dbms_output.put_line(v_table);

exit when my_cursor%NOTFOUND;

v_sql:='Insert into SCOTT.TCOL(A,B) select '||''''|| v_table||''''||','||''''|| v_col||''''||' from SCOTT.'||v_table||' where '||v_col||'=1100';

dbms_output.put_line(v_sql);

EXECUTE IMMEDIATE v_sql;

end loop;

close my_cursor;

end;

以上仅参考!

oracle如何实现遍历查询?

cursor t_name is select teachername from teacher---------申明游标t_name为从teacher表中查询老师名字

open t_name;------打开游标t_name

loop-------开始循环(遍历)

fetch t_name into teacher_name-------将老师名字值赋予变量teacher_name

if t_name%found-------------开始遍历有值时插入以下数据

then

select name,count(*) into new_table

from table_teacher_student

where name=teacher_name group by name-----将一个老师名字依据条件插入新表数据

else

dmbs_output.put_line('完成所有工作');---------遍历结束时输出完成工作

exit;

end if;

仓促写下以上内容,可能部分语法报错,思路就是这样,很基本的一个游标使用.

oracle中如何根据表中一个字段遍历数据

写个for循环就可以遍历一遍,例如meminfo 表中有member_id 你现在有的id需要在meminfo 中查询出现次数

for rec in(select member_id from meminfo) loop

if member_id=id

then i:=i+1;

end if;

这样就会遍历一遍你的这个数据库

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章