程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SyBase數據庫 >> SyBase綜合文章 >> PowerBuilder Plugins and Internet Explorer

PowerBuilder Plugins and Internet Explorer

編輯:SyBase綜合文章

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) PRIMARY 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) PRIMARY 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) PRIMARY KEY)
CONNECT USER developer1 IDENTIFIED BY passWord
CREATE TABLE "mytable" (mycolumn CHAR(10) PRIMARY 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 a


您正在看的Sybase教程是:PowerBuilder Plugins and Internet Explorer。s 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.
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved