0

是否可以通过将参数传递给 JDBC URL 来强制所有 create table 语句使用特定的 database.tablespace?例如,而不是手动指定它如下

CREATE TABLE Message (id INTEGER NOT NULL, created TIMESTAMP, message VARCHAR(255),PRIMARY KEY (id))     in DATABASE.TABLESPACE

我想在连接 URL 中指定“database.tablespace”并执行

CREATE TABLE Message (id INTEGER NOT NULL, created TIMESTAMP, message VARCHAR(255), PRIMARY KEY (id))
4

1 回答 1

0

DB2 完全缺乏您需要的概念。它将用户有权访问的第一个表空间作为“默认”处理:

IF table space IBMDEFAULTGROUP (over which the user
  has USE privilege) exists with sufficient page size
    THEN choose it
ELSE IF a table space (over which the user has USE privilege)
  exists with sufficient page size (see below when
  multiple table spaces qualify)
    THEN choose it
ELSE return an error (SQLSTATE 42727) 

因此,实现您所需的方法是从除一个表空间之外的所有表空间中删除访问权限,即。

-- repeat for all tablespaces
revoke use of tablespace myspace1 from public
revoke use of tablespace myspace1 from user/group xxx
-- and make sure the ones you really need have access rights
grant use of tablespace myspace1 to user creatoruser

当然,这需要你很好地计划你的行动,但这种方法是有效的。

于 2011-09-17T21:34:54.793 回答