gpt4 book ai didi

sql - 使用 SQL 查询确定表是否存在

转载 作者:行者123 更新时间:2023-12-03 15:19:52 25 4
gpt4 key购买 nike

伙计们,除了下面之外,还有其他方法可以确定表是否存在

  • select count(*) from <table> where rownum =1
  • select * from user_table where table_name=<table>

  • 请让我知道使用 oracle sql 检查表是否存在的最佳方法。

    感谢您的回答,我的要求是从当月的第一个日期开始检查,即 01/12/2010,表名格式为suresh_20101201 存在于数据库中,如果没有,则应检查表suresh_20101202 并在其上检查suresh_20101231。是否可以在 oracle sql 查询中进行。

    最佳答案

    你可以这样做(在 oracle 中,在 mssql 中有点不同):

    select count(*)
    from all_objects
    where object_type in ('TABLE','VIEW')
    and object_name = 'your_table_name';

    关于sql - 使用 SQL 查询确定表是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4385346/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com