1. 创建 sequence
create sequence seq_img
minvalue 1
maxvalue 21
start with 1
increment by 1
nocache
nocycle
order;
2. 创建 sequence 以后, 第一次使用 sequence.currval 错误
SQL> select seq_img.currval from dual ;
select seq_img.currval from dual
ORA-08002: 序列 SEQ_IMG.CURRVAL 还没有在此会话中定义
3. 先使用 sequence 的 nextval 方法, 再使用 currval 方法, 错误消失
SQL> select seq_img.nextval from dual ;
NEXTVAL
----------
1
SQL> select seq_img.currval from dual ;
CURRVAL
----------
1
4. 修改数据表中某一列的类型
SQL> alter table image_lob modify t_id number;
Table altered
5. 调用存储过程
SQL> CALL IMG_INSERT(seq_img.nextval,'1.png');
CALL IMG_INSERT(seq_img.nextval,'1.png')
ORA-06576: 不是有效的函数或过程名
SQL> exec IMG_INSERT(seq_img.nextval,'1.png');
PL/SQL procedure successfully completed
6.查看结果
SQL> select * from image_lob;
T_ID T_IMAGE
---------- -------
6 <BLOB>
7.对数据表中某一列的相关操做
对字段操做 操做方法
更新字段名 alter table TABLE_NAME rename column column_old to column_new;
添加字段 alter table TABLE_NAME add COLUMN_NAME varchar(10);
删除字段 alter table TABLE_NAME drop column COLUMN_NAME;
添加字段并附值 alter table TABLE_NAME ADD COLUMN_NAME NUMBER(1) DEFAULT 1;
修改字段值 update TABLE_NAME set filedname=value where filedname=value;
修改字段数据类型 alter table tablename modify filedname varchar2(20);
8. 在insert 语句中使用 sequence
inert into tablename values(seq_img.nextval,...............); 函数
参考: .net
http://blog.csdn.net/a19881029/article/details/8961053 blog