是否可以通过将参数传递给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))
答案 0 :(得分: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
当然,这需要你很好地规划你的行动,但这种方法是有效的。