巷尾的酒吧

            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 閱讀(1253) 評論(0)  編輯  收藏 所屬分類: oracle
          主站蜘蛛池模板: 关岭| 交城县| 北京市| 突泉县| 二连浩特市| 利川市| 黑山县| 渝北区| 陇川县| 湘西| 通化县| 东乡县| 湛江市| 巴中市| 乌苏市| 梁平县| 洪江市| 尼玛县| 临湘市| 永定县| 台东县| 司法| 岐山县| 湘乡市| 农安县| 通辽市| 库尔勒市| 曲靖市| 土默特右旗| 隆林| 辽宁省| 蒲城县| 交口县| 方城县| 泸州市| 抚宁县| 辽宁省| 淮安市| 太湖县| 丹江口市| 阆中市|