문제

When i write:

if not exists (select * from sys_maxkey)

is better,or

if not exists (select id from sys_maxkey)

is better when the table sys_maxkey variable.

or it has no difference?I have found internet and analyse exists and in but not pay attention to this special point.

Thank you!

도움이 되었습니까?

해결책

I would suggest to use only 1 like this. This would be the best. As exists only checks whether there is any entry in your table.

if not exists (select 1 from sys_maxkey)

Although if you want to compare between the above two mentioned in your question then

if not exists (select id from sys_maxkey)

would be better provided that id is the primary key. You dont have to check all the columns by using * just for checking whether there exists a value in your table.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top