CONNECT TO CST user ;
//主键自动维护fileid
CREATE TABLE COLLECT_FILE_LIST ( FILEID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1, NO CACHE ) , FILENAME VARCHAR (128) , CONSTRAINT CC1294652905796 PRIMARY KEY ( FILEID) ) IN USERSPACE1 ;
CONNECT RESET;
其中GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1, NO CACHE ) 意思为自动生成主键,从1开始,每次增加步长为1,NO CACHE指发生故障情况下不废弃未使用的标识符
CONSTRAINT CC1294652905796 PRIMARY KEY ( FILEID)意思为FILEID作为主键,约束名为CC1294652905796
IN USERSPACE1为用户空间,可以不写。
如此插入数据时便可以不用写主键值了,这样其标识符是由数据库自动进行维护,如下SQL语句操作:
insert into COLLECT_FILE_LIST (filename) values('filename')