gpt4 book ai didi

oracle - 在没有 DBA 权限的情况下更改不同数据库下的许多模式的密码?

转载 作者:行者123 更新时间:2023-12-02 04:40:36 24 4
gpt4 key购买 nike

我们在不同的数据库下有很多模式。我没有 DBA 权限。我确实有登录模式和更改密码的特权。我们会在六个月内更改密码。目前,这是一个手动且耗时的过程。即登录到数据库下的每个模式并使用“密码”命令更改密码。当我更改密码时,我有两个文件——当前密码和新密码。

我登录到每个 schema@database 并发出以下命令 –

alter user schema_name  identified by new_password  replace  old_password;

请记住,我没有 DBA 权限;我只能使用用户名和密码登录模式。

我考虑过创建 shell 脚本并使用 shell 脚本中的“expect”。尽管首先尝试找出是否有更简单的方法。我想知道是否有从 SQL*Plus 或从 PL/SQL 执行此操作的简单方法?

最佳答案

使用 PLSQL 或 SQL*Plus 似乎是不可能的,因为同时使用它们时,您只能从单个模式执行,并且由于没有 DBA 权限,您不能对所有模式执行此操作,而最终会登录每个模式后运行脚本。

您可以编写一个 shell 脚本来读取这两个文件,并且对于每一行,它将以下数据插入到第三个文件中,

sqlplus -s username_1/old_password_1@oracle_instance <<EOF
alter user username_1 identified by new_password1 replace old_password_1;
exit
EOF

sqlplus -s username_2/old_password_2@oracle_instance <<EOF
alter user username_2 identified by new_password_2 replace old_password_2;
exit
EOF
.
.
.

sqlplus -s username_n/old_password_n@oracle_instance <<EOF
alter user username_n identified by new_password_n replace old_password_n;
exit
EOF

等等

创建第三个文件后,将其权限设置为_rwxrwxrwx后执行

关于oracle - 在没有 DBA 权限的情况下更改不同数据库下的许多模式的密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20923581/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com