锁定老帖子 主题:oracle使用序列笔记
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2011-03-14
create sequence SEQ_SYS_HEYJDEMO_FOLDER_ID MINVALUE 1 MAXVALUE 999999999999999999999999999 increment by 1 nocache; create sequence SEQ_SYS_HEYJDEMO_FILE_ID MINVALUE 1 MAXVALUE 999999999999999999999999999 increment by 1 nocache;
drop sequence SEQ_SYS_HEYJDEMO_FOLDER_ID ; drop sequence SEQ_SYS_HEYJDEMO_FILE_ID ; -- heyjdemo 文件夹表 create table heyjdemo_folders( ID number(19,0) not null primary key, -- 文件夹标识 parentID number(19,0) not null, foldername varchar2(255) not null, -- 文件夹名称 folderinfo varchar2(2000), -- 文件夹描述 fileiconurl varchar2(500) -- 文件夹图标路径 );
-- heyjdemo 文件表 create table heyjdemo_files( ID number(19,0) not null primary key, -- 文件标识 folderID number(19,0) not null constraint heyjdemo_files_ID_FK references heyjdemo_folders(ID) on delete cascade, -- 文件夹标识 filename varchar2(500) not null, -- 文件名 filetype char(10), -- 文件类型 filesize number(19,2), -- 文件大小 fileinfo varchar2(2000), -- 文件描述 fileurl varchar2(500) not null, -- 文件路径 fileiconurl varchar2(500) -- 文件图标 );
-- 向heyjdemo_folders插入记录 insert into heyjdemo_folders (ID, parentID, foldername, folderinfo) values(SEQ_SYS_HEYJDEMO_FOLDER_ID.Nextval,'0','计算机科学','计算机科学'); insert into heyjdemo_folders (ID, parentID, foldername, folderinfo) values(SEQ_SYS_HEYJDEMO_FOLDER_ID.Nextval,'0','文学','文学'); insert into heyjdemo_folders (ID, parentID, foldername, folderinfo) values(SEQ_SYS_HEYJDEMO_FOLDER_ID.Nextval,'1','数据结构','数据结构'); insert into heyjdemo_folders (ID, parentID, foldername, folderinfo) values(SEQ_SYS_HEYJDEMO_FOLDER_ID.Nextval,'1','C语言','C语言'); insert into heyjdemo_folders (ID, parentID, foldername, folderinfo) values(SEQ_SYS_HEYJDEMO_FOLDER_ID.Nextval,'0','c#','c#'); insert into heyjdemo_folders (ID, parentID, foldername, folderinfo) values(SEQ_SYS_HEYJDEMO_FOLDER_ID.Nextval,'0','oracle','oracle'); insert into heyjdemo_folders (ID, parentID, foldername, folderinfo) values(SEQ_SYS_HEYJDEMO_FOLDER_ID.Nextval,'5','数据库','数据库'); insert into heyjdemo_folders (ID, parentID, foldername, folderinfo) values(SEQ_SYS_HEYJDEMO_FOLDER_ID.Nextval,'5','mysql','mysql'); insert into heyjdemo_folders (ID, parentID, foldername, folderinfo) values(SEQ_SYS_HEYJDEMO_FOLDER_ID.Nextval,'5','java','java'); insert into heyjdemo_folders (ID, parentID, foldername, folderinfo) values(SEQ_SYS_HEYJDEMO_FOLDER_ID.Nextval,'0','jsp','jsp'); insert into heyjdemo_folders (ID, parentID, foldername, folderinfo) values(SEQ_SYS_HEYJDEMO_FOLDER_ID.Nextval,'0','我的文档','我的文档');
-- 向heyjdemo_files中插入记录 insert into heyjdemo_files (ID, folderID, filename, fileurl) values(SEQ_SYS_HEYJDEMO_FILE_ID.Nextval, 1, '计算机教程' ,'/' ); insert into heyjdemo_files (ID, folderID, filename, fileurl) values(SEQ_SYS_HEYJDEMO_FILE_ID.Nextval, 4, 'c语言教程' ,'/'); insert into heyjdemo_files (ID, folderID, filename, fileurl) values(SEQ_SYS_HEYJDEMO_FILE_ID.Nextval, 3, '数据结构教程' ,'/'); insert into heyjdemo_files (ID, folderID, filename, fileurl) values(SEQ_SYS_HEYJDEMO_FILE_ID.Nextval, 1, 'tt' ,'/'); insert into heyjdemo_files (ID, folderID, filename, fileurl) values(SEQ_SYS_HEYJDEMO_FILE_ID.Nextval, 5, 'ttt' ,'/'); insert into heyjdemo_files (ID, folderID, filename, fileurl) values(SEQ_SYS_HEYJDEMO_FILE_ID.Nextval, 8, 'tttt' ,'/'); 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2011-03-30
怎么修改序列??
|
|
返回顶楼 | |
发表时间:2011-03-30
创建序列有什么要求嘛,或者说有什么规则吗
|
|
返回顶楼 | |
发表时间:2011-03-30
最后修改:2011-03-30
我也只知道这么用,但不明白为什么要这么用,在做插入操作时,要看看序列的最大值,如果id小于序列的值,就会报错。
|
|
返回顶楼 | |
浏览 2752 次