WEB开发网
开发学院数据库Sybase PowerBuilder Plugins and Internet Explorer 阅读

PowerBuilder Plugins and Internet Explorer

 2006-03-14 21:46:28 来源:WEB开发网   
核心提示:liminating the need to preface the object name with the owner nameMany developers create all their objects with dba as the owner.This is reasonable since the db

liminating the need to preface the object name with the owner name

  Many developers create all their objects with dba as the owner.This is reasonable since the dba user is already on the database and has rights to everything in the system.The problem comes when adding users to the system and granting them rights to the database objects.Most developers start out like this:

CREATE TABLE mytable (mycolumn CHAR(10) Prima(最完善的虚拟主机管理系统)RY KEY)
GRANT CONNECT TO mygroup
GRANT GROUP TO mygroup
GRANT CONNECT TO myuser IDENTIFIED BY mypassword
GRANT MEMBERSHIP IN GROUP mygroup TO myuser
GRANT SELECT,INSERT,UPDATE,DELETE ON mytable TO mygroup

  This works just fine if you construct your queries like this:

SELECT * FROM "dba"."mytable" 

  However, if the query is constructed like this and executed by "myuser" then it will fail with a "Table 'mytable' not found" error:

SELECT * FROM "mytable"

  The following query will work, however some problems have been seen with earlier versions of the database engine where it didn't like to see the dba user without double quotes around it. 

SELECT * FROM dba."mytable"

  "dba" is also a keyword and that can cause problems.

  To completely eliminate the need to preface the object name with the name of the owner you should upgrade the "dba" user to a group and then grant rights off of that group.  Here is a sample of how to do it.

GRANT GROUP TO "dba"
CREATE TABLE mytable (mycolumn CHAR(10) Prima(最完善的虚拟主机管理系统)RY KEY)
GRANT CONNECT TO mygroup
GRANT GROUP TO mygroup
GRANT MEMBERSHIP IN GROUP "dba" TO mygroup
GRANT CONNECT TO myuser IDENTIFIED BY mypassword
GRANT MEMBERSHIP IN GROUP mygroup TO myuser
GRANT SELECT,INSERT,UPDATE,DELETE ON mytable TO mygroup

  Once this is completed the following query will work just fine when logged in as "myuser":

SELECT * from "mytable"

  An Alternative

  Some developers prefer to not have the "dba" user as the owner of all the objects.  Much of this preference stems from the use of dba as a keyword.  To resolve this, create a new user, upgrade the user to a group and then create all objects with that user as the owner.

  One Reason To Avoid Prefacing

  During development it is often necessary for developers to create their own tables to test with.  If your application prefaces all the database objects with the owner name then the developer cannot utilize the temporary table.  For example:

CONNECT USER dba IDENTIFIED BY sql
CREATE TABLE "dba". "mytable" (mycolumn CHAR(10) Prima(最完善的虚拟主机管理系统)RY KEY)
CONNECT USER developer1 IDENTIFIED BY password
CREATE TABLE "mytable" (mycolumn CHAR(10) Prima(最完善的虚拟主机管理系统)RY KEY)
Now, when the user "developer1" queries "mytable" they will be 
working against their own table instead of the table that is owned by "dba":
SELECT * from "mytable"

  In PowerBuilder if you are logged in to the database as the owner of the objects then the SQL painters will construct SQL without the owner name.  If you are logged in as a user other than the owner (but with rights to the object) then your SQL will be constructed with the owner name prefacing the objects.

Tags:PowerBuilder Plugins and

编辑录入:coldstar [复制链接] [打 印]
赞助商链接