question :
query from table peron ,validate are there any records which name = C
table person like below :
id | name
1 A
2 B
3 C
4 C
5 C
SQL 1 : (more common) SELECT COUNT(*) FROM PERSON WHERE NAME = 'C';
SQL 2 : SELECT 1 FROM DUAL WHERE EXISTS (SELECT * FROM PERSON WHERE NAME = 'C');
COUNT(*) will scan all rows in the person table ,if the record in person is more than 1 million one query may cost many time ; but if we use the exists ,the scan will return immediately when the record been scanned .
本文探讨了两种不同的SQL查询方法:一种使用COUNT(*)来统计特定记录的数量;另一种利用EXISTS进行存在性验证。当数据量庞大时,后者因其立即返回特性而更加高效。
370

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



