/*
调用存储过程:
1.exec sayhelloworld();
2.begin
sayhelloworld();
sayhelloworld();
end;
/
*/
create or replace procedure sayhelloworld
as
--说明部分
begin
dbms_output.put_line('Hello World');
end;
/
调用oracle存储过程:
windows的DOS窗口连接oracle数据库:
sqlplus fxf/fxf@127.0.0.1:1521/orcl
1)SQL> set serveroutput on
SQL> exec sayhelloworld();
Hello World
2)begin
sayhelloworld();
sayhelloworld();
end;
/
创建sequence语句:
CREATE SEQUENCE seq_name-- seq_name为计数器的名字,自定;
INCREMENT BY 1 -- 每次加幅度:1,2,3,....;
START WITH 1 -- 起始序号,以实际生产情况而定;
NOMAXvalue -- 不设置最大值,或设定最大值: maxvalue 9999;
NOCYCLE -- 一直累加,不循环; 或循环使用 cycle ;
CACHE 10; --设置缓存序列个数,如果系统down掉了或者其它情况将会导致序列不连续,也可以设置为---------NOCACHE
创建表从其他表中复制字段和数据:
create table userinfo_new
as
select * from userinfo;
在添加时复制:
insert into userinfo_new
select * from userinfo;(字段类型必须匹配)
insert into userinfo_new(id,username)
select (id,username) from userinfo;