简体   繁体   中英

Script - Have I formatted multiple values correctly?

If I use the following script, it deletes a information from our database.

I have a few hundred users to delete. I wanted to include them in one script and delete them all. The thing I can't remember is if I can comma delineate them to include them in a single query or not

So if I have the following 3 users, would the script below work correctly to delete all 3 of them?

使用in子句:

delete from FILE_Users where USER_ID in ('USER/Jo.Ann', 'USER/Mike.Jordan', 'USER/Jim.Buss')

您想使用IN进行多次删除

delete from FILE_Users where USER_ID IN ('USER/Jo.Ann','USER/Mike.Jordan', 'USER/Jim.Buss')

You can use in clause

delete from FILE_Users 
where USER_ID in ( 'USER/Jim.Buss', 'USER/Jo.Ann', 'USER/Mike.Jordan');

The IN clause will allow upto 1024 values. If you have more than that then you have multiple options. One among them is split the comma separated string and use these as table using the connect by query. This might make the query slower though. Or Put this string as external table and using regular expression count and split the values at each comma and delete. Good luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM