如何更改在 SQL Developer for Oracle 12c 中连接的用户?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43585647/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:24:55  来源:igfitidea点击:

How to change user which is connected in SQL Developer for Oracle 12c?

oracleoracle-sqldevelopersqlplusoracle12c

提问by j.key

I created a user and granted it privileges but I cannot connect to the database as that user from SQL Developer.

我创建了一个用户并授予它权限,但我无法从 SQL Developer 以该用户身份连接到数据库。

When I enter the code in SQL*Plus it shows that it has connected as in the picture below

当我在 SQL*Plus 中输入代码时,它显示它已连接如下图

picture

图片

However when I try the same thing in Oracle SQL Developer, it shows me SYS user.

但是,当我在 Oracle SQL Developer 中尝试同样的事情时,它显示我是 SYS 用户。

enter image description here

在此处输入图片说明

How to fix this?

如何解决这个问题?

EDIT

编辑

picture

图片

回答by Alex Poole

In your SQL Developer screen shot you're looking at the 'Other Users' section of the navigation panel on the left, under your existing connection as SYS.

在您的 SQL Developer 屏幕截图中,您正在查看左侧导航面板的“其他用户”部分,在您作为 SYS 的现有连接下。

You cantemporarily change to another user in that SQL Worksheet by doing:

可以通过执行以下操作临时更改为该 SQL 工作表中的另一个用户:

connect c##murat/<password>

and then if you run as a script the statements after that will be performed as that user - and it will disconnect and revert to SYS when the script finishes.

然后,如果您作为脚本运行,则之后的语句将作为该用户执行 - 当脚本完成时,它将断开连接并恢复为 SYS。

But I wouldn't recommend that, except maybeas part of a schema-build script where you might want to switch back and forth. Particularly when you're really connected SYS. It's too easy to accidentally run something as the wrong user.

但我不会建议,除了可能作为一个模式,构建脚本,你可能要来回切换的一部分。特别是当您真正连接到 SYS 时。以错误的用户身份意外运行某些东西太容易了。

Really you need to create a new connection. At the top of the 'Connections' panel, click the green plus symbol and find your current connection in the list. Change the connection name (important!), username and password, set the role to 'default', click 'Test' to verify, and then click 'Save'.

实际上,您需要创建一个新连接。在“连接”面板的顶部,单击绿色加号并在列表中找到您当前的连接。更改连接名称(重要!)、用户名和密码,将角色设置为“默认”,单击“测试”进行验证,然后单击“保存”。

You will then have two connections, and you can choose which to connect to and open SQL Worksheets as. As you're hopefully aware, you should not do any normal work as SYS, so you'll rarely need to connect as that again. I'd suggest you make it obvious in the connection name which is which, and that will appear in unsaved worksheet titles; and maybe use the connection colour option to further highlight and give you some visual warning when you are connecting as SYS.

然后您将有两个连接,您可以选择连接到哪个连接并打开 SQL 工作表。正如您希望知道的那样,您不应该以 SYS 身份执行任何正常工作,因此您很少需要再次连接。我建议您在连接名称中明确说明这是哪个,这将出现在未保存的工作表标题中;当您以 SYS 身份连接时,也许可以使用连接颜色选项进一步突出显示并给您一些视觉警告。

When you are connected as your new user, you will not see their name in the 'Other Users' list. You will see SYS though.

当您作为新用户连接时,您将不会在“其他用户”列表中看到他们的姓名。不过你会看到 SYS。