The fastest way to check if some records in a database table?

前端 未结 6 1445
耶瑟儿~
耶瑟儿~ 2020-12-14 22:44

I have a huge table to work with . I want to check if there are some records whose parent_id equals my passing value . currently what I implement this is by using \"select

6条回答
  •  天命终不由人
    2020-12-14 23:50

    This query will return 1 if any record exists and 0 otherwise:

    SELECT COUNT(1) FROM (SELECT 1 FROM mytable WHERE ROWNUM < 2);
    

    It could help when you need to check table data statistics, regardless table size and any performance issue.

提交回复
热议问题