Oracle主键自动增长
Oracle主键自动增长
这几天搞Oracle,想让表的主键实现自动增长,查网络实现如下:
create table simon_example
(
id number(4) not null primary key,
name varchar2(25)
)
-- 建立序列:
-- Create sequence
create sequence SIMON_SEQUENCE
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
cache 20;
-- 建立触发器
create trigger "simon_trigger" before
insert on simon_example for each row when(new.id is null)
begin
select simon_sequence.nextval into:new.id from dual;
end;
相关文档:
自从学ORACLE以来就从来没有发生过什么故障,比较幸运。其实也不能算幸运,因为这样就少了锻炼的机会了,呵呵,怎么觉得自己有点求虐的倾向……
即便是在学习backup and recovery basics的时候,也只是做做备份的实验,没做过恢复,因为身边没有人指导,也没其他同学在学ORACLE,所以怕一出问题肯定很麻烦,解 ......
select 'create sequence '||sequence_name||
' minvalue '||min_value||
' maxvalue '||max_value||
' start with '||last_number||
&n ......
一:
使用Profile对用户Session会话进行资源限制
--但是如果使用了连接池之类的东东,就会出些问题,比如前台连接不上之类的
--http://www.eygle.com/archives/2008/10/profile_session_limit.html
sqlplus "/ as sysdba"
SQL> show parameter resource
SQL> alter system set resource_limit= ......
CREATE OR REPLACE PROCEDURE sendemailtest
(mailmsg IN Varchar2)
IS
--using mail server to send email.
mailconn UTL_SMTP.connection;
mailhost & ......
select trim(leading | trailing | both ' ' from ' abc d ') from dual;
去掉字符串 ' abc d ' 的前面/后面/前后的空格
类似函数:ltrim, ......