简体   繁体   English

脚本-我是否正确格式化了多个值?

[英]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? 因此,如果我有以下3个用户,下面的脚本是否可以正常工作以删除所有3个用户?

使用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 您可以使用in子句

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. IN子句最多允许1024个值。 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 祝好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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