分类:
2009-03-10 10:41:17
1.创建数据库lgxswfc
db2 create database lgxswfc on f:\db2 dbpath on f:
2.创建的lgxswfc的tablespace
db2 connect to lgxswfc
db2 create tablespace tbs1 managed by database using ( file 'f:\db2\tbs\tbs1.dbf' 10M)
db2 create tablespace tbs2 managed by database using ( file 'f:\db2\tbs\tbs2.dbf' 10M)
db2 create tablespace tbs3 managed by database using ( file 'f:\db2\tbs\tbs3.dbf' 10M)
db2 create tablespace tbs4 managed by database using ( file 'f:\db2\tbs\tbs4.dbf' 10M)
db2 create tablespace tbs5 managed by database using ( file 'f:\db2\tbs\tbs5.dbf' 10M)
db2 create tablespace tbs6 managed by database using ( file 'f:\db2\tbs\tbs6.dbf' 10M)
#db2数据库不支持 函数索引 和 函数分区
3.
++++++++++++++my.db2++++++++++++++++++
CREATE TABLE lgxswfc(
NAME VARCHAR (20),
dayofweek int NOT NULL,
remark varchar(20))
PARTITION BY RANGE(dayofweek NULLS LAST)
(
STARTING FROM (1) INCLUSIVE ENDING AT (2) EXCLUSIVE IN TBS1,
STARTING FROM (2) INCLUSIVE ENDING AT (3) EXCLUSIVE IN TBS2,
STARTING FROM (3) INCLUSIVE ENDING AT (4) EXCLUSIVE IN TBS3,
STARTING FROM (4) INCLUSIVE ENDING AT (5) EXCLUSIVE IN TBS4,
STARTING FROM (5) INCLUSIVE ENDING AT (6) EXCLUSIVE IN TBS5,
STARTING FROM (6) INCLUSIVE ENDING AT (7) EXCLUSIVE IN TBS6,
STARTING FROM (7) INCLUSIVE ENDING AT (MAXVALUE) EXCLUSIVE IN TBS6
) INDEX IN TBS1;
++++++++++++++++++++++++++++++++
db2 -svtf F:\db2\tbs\my.db2 -z F:\db2\tbs\log.txt
查看表分区信息
db2 describe data partitions for table lgxswfc show detail
db2 insert into lgxswfc(name,dayofweek,remark) values('a',1,'aa')
db2 insert into lgxswfc(name,dayofweek,remark) values('c',7,'cc')
db2 insert into lgxswfc(name,dayofweek,remark) values('d',0,'dd')
#插入非范围内数据出错
==============
E:\IBM\SQLLIB\BIN>db2 insert into lgxswfc(name,dayofweek,remark) values('d',0,'d
d')
DB21034E 该命令被当作 SQL 语句来处理,因为它是无效的“命令行处理器”命令。在
SQL 处理期间,它返回:
SQL0327N 无法将行插入表 "administrator.LGXSWFC"
中,因为它在定义的数据分区范围之外。 SQLSTATE=22525
==============