Oracle中判断表是否存在!
declare v_cnt Number;
begin
select count(*) into v_cnt from user_tables where table_name = 'YOURTABLENAME';
if v_cnt>0 then
dbms_output.put_line('该表存在!');
else
dbms_output.put_line('该表不存在或当前用户无权访问!');
end If;
End;
begin
select count(*) into v_cnt from user_tables where table_name = 'YOURTABLENAME';
if v_cnt>0 then
dbms_output.put_line('该表存在!');
else
dbms_output.put_line('该表不存在或当前用户无权访问!');
end If;
End;
本文提供了一段PL/SQL代码示例,用于检查指定名称的表是否存在于Oracle数据库中。通过查询USER_TABLES视图并统计结果数量来实现这一目标。如果表存在,则输出相应的消息。
285

被折叠的 条评论
为什么被折叠?



