巷尾的酒吧

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            64 Posts :: 0 Stories :: 5 Comments :: 0 Trackbacks
          oracle 創建表table:
          create table abin1(
          id number(20,0) not null,
          name varchar2(100)not null,
          pwd nvarchar2(100) not null,
          create_time date,
          constraint pk_abin1 primary key(id)
          )

          oracle創建索引(index):
          create index myname on abin1(name);

          oracle創建序列sequence:
          create sequence abin1_seq
          minvalue 1
          maxvalue 999999999
          start with 1
          increment by 1
          cache 20;
          創建觸發器:
          create or replace trigger abin1_tri
          before insert on abin1
          for each row
          begin
          select abin1_seq.nextval into :new.id from dual;
          end;


          測試一條記錄:
          insert into abin1 (name,pwd,create_time) values ('abin','lee',sysdate); 
          呵呵,這里插入了數據,主鍵自增了,說明成功了。


          創建存儲過程procedure:
          create or replace procedure abin1_pro
          is
          cursor mycur is select t.* from abin1 t;
          abin mycur%rowtype;
          begin
               open mycur;
               loop
                  fetch mycur into abin;
                  if(abin.name='abin')then
                        update abin1 t set t.name='abining',t.pwd=abin.pwd,t.create_time=sysdate where t.id=abin.id;
                        commit;
                  end if;
                  exit when mycur%NOTFOUND;
               end loop;
                  if(mycur%ISOPEN)then
                       close mycur;
                  end if;
          end;


          測試存儲過程示例:
          declare
          begin
                  abin1_pro;
          end;


          創建oracle函數function:
          create or replace function abin_func
          return number
          is
          total number;
          begin
          select count(1) into total from abin1 t;
          return(total);
          end;


          創建測試函數示例:
          declare
          total number;
          begin
                total:=abin_func;
                dbms_output.put_line(total);
          end;


          oracle創建視圖:
          create or replace view abin1_view
          as
          select t.* from abin1 t;


          oracle創建package:
          create or replace package abin_pac is
          procedure abinpac;
          end;


          oracle創建package body:
          create or replace package body abin_pac is
          procedure abinpac is
          total number;
          begin
           select count(1) into total from abin1;
           dbms_output.put_line(total);
          end;
          end;

          測試代碼:
          begin
           abin_pac.abinpac;
          end;



          posted on 2013-06-02 23:26 abing 閱讀(1252) 評論(0)  編輯  收藏 所屬分類: oracle
          主站蜘蛛池模板: 元朗区| 长葛市| 和林格尔县| 洛扎县| 邹城市| 疏勒县| 连平县| 呼图壁县| 洱源县| 揭阳市| 丰原市| 青阳县| 博湖县| 合肥市| 夏津县| 武清区| 武穴市| 岳阳县| 吴堡县| 永登县| 浪卡子县| 历史| 安顺市| 天峻县| 延长县| 南川市| 云龙县| 洮南市| 闽清县| 马关县| 潢川县| 兴宁市| 周宁县| 宜宾市| 江油市| 华池县| 皋兰县| 云阳县| 吉隆县| 乌恰县| 遵化市|