设置DB2和IBM Data Studio时遇到无休止的问题。

huangapple go评论50阅读模式
英文:

Endless troubles with setting up DB2 and IBM Data Studio

问题

I have to use DB2 for a course at my faculty. I'm on Windows 10, installed DB2 express C, installed Data Studio. During the installation I've used 'db2admin' as the username and 'admin' as the password. Then I ran a series of SQL scripts provided by our faculty to generate all the tables that we need and to populate them. That apparently worked as well.

Here's the problem. All the tables were made under that schema 'aleksa' which happens to be my computer username.

From the command line I can do everything just fine. Data studio is the problem. When connecting to the database I use the uppermentioned db2admin and admin as the credentials. At first, when I tried to run any query I kept getting some authorization errors. So then I googled for a while and found that I needed to grant access to db2admin on those tables (why an admin account needs granting of anything beats me). So I've done that by connecting to the database from the command line (by the way, the command line never requires me to enter any credentials whatsoever), and running a series of

grant select on <table_name> to user db2admin

I've no idea whether I should have but I also, just in case, ran

grant all on <table_name> to user db2admin

all of those, of course, for each table that I have.

And each one of them ran successfully. After doing that I no longer get the authorization error in Data Studio when running queries. But I also don't get anything.

To repeat, running queries from the command line works fine which is why I know that the database is fine and that I actually have data in it. Which is also why I know that the output for the very same query ran from Data Studio instead of the command line shouldn't be just the query execution time and no results in the 'SQL results' window. In my case the queries that I've tried were simply 'select * from aleksa.table_name'. They produce a bunch of rows in the command line, but none in Data Studio.

So, any ideas?

英文:

I have to use DB2 for a course at my faculty. I'm on Windows 10, installed DB2 express C, installed Data Studio. During the installation I've used 'db2admin' as the username and 'admin' as the password. Then I ran a series of SQL scripts provided by our faculty to generate all the tables that we need and to populate them. That apparently worked as well.

Here's the problem. All the tables were made under that schema 'aleksa' which happens to be my computer username.

设置DB2和IBM Data Studio时遇到无休止的问题。

From the command line I can do everything just fine. Data studio is the problem. When connecting to the database I use the uppermentioned db2admin and admin as the credentials. At first, when I tried to run any query I kept getting some authorization errors. So then I googled for a while and found that I needed to grant access to db2admin on those tables (why an admin account needs granting of anything beats me). So I've done that by connecting to the database from the command line (by the way, the command line never requires me to enter any credentials whatsoever), and running a series of

grant select on &lt;table_name&gt; to user db2admin

I've no idea whether I should have but I also, just in case, ran

grant all on &lt;table_name&gt; to user db2admin

all of those, of course, for each table that I have.

And each one of them ran successfully. After doing that I no longer get the authorization error in Data Studio when running queries. But I also don't get anything.

To repeat, running queries from the command line works fine which is why I know that the database is fine and that I actually have data in it. Which is also why I know that the output for the very same query ran from Data Studio instead of the command line shouldn't be just the query execution time and no results in the 'SQL results' window. In my case the queries that I've tried were simply 'select * from aleksa.table_name'. They produce a bunch of rows in the command line, but none in Data Studio.

So, any ideas?

答案1

得分: 1

Db2按设计运行。

您的问题与编程无关,而是与管理和运营方面有关。

如果您没有关于Db2的基本教育,可能会遇到“无休止的问题”。

在使用Db2之前,考虑获得一些关于Db2的教育,或者学习适用于您的Db2版本的免费在线Db2知识中心,直到您理解所需的概念。

Stack Overflow不能替代教育。

如果您在DataStudio中使用与创建对象的相同凭据连接,那么引用这些对象的查询将默认情况下不会出现访问错误,并且将看到对象中存在的数据。

如果您不希望模式名称是“aleksa”,而是希望模式名称改为“db2admin”,那么在连接到数据库作为db2admin时重新运行脚本(如果两个模式不符合,则还可以首先由帐户aleksa删除所有现有对象)。

如果您使用与创建者不同的凭据连接,根据脚本的操作,可能会出现访问错误。我们无法查看脚本的操作,它们可能已经对表应用了非默认权限,或者使用了角色,或者需要特定的组成员资格等。我们也无法查看您的Db2配置。假设您能够查看此类详细信息。

默认情况下,在当前版本的Db2中,db2admin帐户不是SECADM,因此db2admin无法获得数据访问权限,而定义为SECADM的帐户可以授予其他帐户数据访问权限和访问控制权限。

如果您的查询完全限定了对象名称(即指定模式和表名称),并且这些对象存在,并且连接帐户具有SELECT权限,并且对象包含数据,那么DataStudio将显示数据(或错误)。

查阅Db2在线文档的相关页面以获取更多详细信息。

DataStudio在Db2方面没有什么特别之处,除了它覆盖所有平台上的Db2功能。IBM Data Studio是一个Java应用程序,还有许多其他类似的工具,涵盖了较少的高级Db2功能。

英文:

The Db2 is working as designed.

Your question is not about programming, but instead it is about administration and operational aspects.

You may experience 'endless troubles' if you don't have basic education in Db2.

Consider getting some education in Db2 before using Db2 , or studying the free online Db2 Knowledge centre for your Db2 version, until you understand the required concepts.

Stakoverflow is not a substitute for education

If you connect (in DataStudio) with the same credentials that created the objects, then queries that reference those objects will not get access errors (by default), and will see data that exists in the objects.

If you don't want the schema-name to be 'aleksa' and you do want the schema name instead to be 'db2admin' then run the scripts again whilst connected to the database as db2admin (and account aleksa can additionally first drop all the existing objects in the alesksa schema if both schemas do not fit).

If you connect with different credentials than those of the creator, you may get access errors depending on what the scripts have done. We cannot see what the scripts have done, they may have applied non-default permissions on the tables, or used roles, or require certain group memberships etc. We also cannot see how your Db2 is configured. Presumably you are able to see such details.

The db2admin account is not (by default, in current versions of Db2) the SECADM, so db2admin does not get data access, and the account defined as the SECADM is able to grant data-access and accessctrl authorities to other accounts.

If your queries fully qualify the object names (i.e specify a schema and a table name), and those objects exist, and the connecting-account has SELECT access, and the object contains data, then DataStudio will show data (or an error).

Study the relevant pages of the Db2 documentation online for more details.

There is nothing special about DataStudio with Db2, apart from the fact it covers all Db2 functionality on all platforms. IBM Data Studio is a java application, and many other similar tools exist with lesser coverage of advanced Db2 functionality.

huangapple
  • 本文由 发表于 2020年1月6日 16:04:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/59608593.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定