使用SQL查询确定表是否存在 [英] Using SQL query to determine if a table exists
问题描述
除了下面的以外,还有其他方法可以确定表是否存在
Guys is there any other way to determine a table exists other than below
-
select count(*) from <table> where rownum =1
-
select * from user_table where table_name=<table>
select count(*) from <table> where rownum =1
select * from user_table where table_name=<table>
请让我知道使用oracle sql检查表是否存在的最佳方法.
kindly let me know the best way to check whether a table exists using oracle sql.
谢谢您的回答,我的要求是从数据库的当前日期的第一天(即01/12/2010)开始检查表名称,格式为suresh_20101201,如果没有,则应检查表suresh_20101202及其之后,直到suresh_20101231.是否可以在oracle sql查询中执行.
Thanks for the answer , my requirement is to check from the first date of current month ie 01/12/2010 with table name in the format suresh_20101201 exists in the database, if not then it should check for table suresh_20101202 and thereon till suresh_20101231 . is it possible to do in oracle sql query.
推荐答案
您可以执行此操作(在oracle中,在mssql中有一些不同):
You can do this (in oracle, in mssql there is a bit different):
select count(*)
from all_objects
where object_type in ('TABLE','VIEW')
and object_name = 'your_table_name';
这篇关于使用SQL查询确定表是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!