如何在 Oracle RDBMS 中按掩码删除用户
我想删除名称开头为“WIN”的所有用户(例如“WIN$DOWS”)。是否可以写类似以下内容的内容?
drop user where name like 'WIN%'
I want to drop all users who have 'WIN' at the start of their name (for example, 'WIN$DOWS'). Is it possible to write something like like the follownig?
drop user where name like 'WIN%'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
DROP USER 语句不支持 WHERE 子句,更不用说 LIKE 和通配符了。
您需要从 DBA_USERS 匹配,并迭代该列表:
The DROP USER statement doesn't support a WHERE clause, much less LIKE and wildcarding.
You need to fetch a list of users from DBA_USERS that match, and iterate over that list:
万一级联删除
In case cascade delete
在没有使用
BEGIN
..EXCEPTION
..END
语法的情况下,我在上述解决方案中遇到了错误。这对我有用:
对于级联删除添加
||
。i.username
之后的“CASCADE”I had an error with the solution above without the
BEGIN
..EXCEPTION
..END
syntax.This works for me:
For a cascading deletion add
|| ' CASCADE'
afteri.username
.