<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Jcat
    寵辱不驚,閑看庭前花開花落~~
    posts - 173,comments - 67,trackbacks - 0
    純好人不用打:白羊

    沒人防:雙子(迷宮)、天平(卡妙的冰箱)、射手(迷宮)

    打死:巨蟹(紫龍)、山羊(紫龍自曝)、雙魚(阿瞬)、水瓶(冰河)

    沒打過,放水:獅子(星矢)、天蝎(冰河)、金牛(星矢)、處女(一輝)


    這樣看來紫龍是最NB的,一個人干掉2個,而且靠他師傅走后門天平不用打,還用天平的武器救了冰河。

    冰河和他師傅干了2仗
    冰河那段也挺NB,先是在天平被凍個半死,然后在天蝎被針扎個半死,最后到了水瓶還能把他師傅干掉
    冰河和他師傅是最體現(xiàn)實力的一仗,純實力對扣

    合著星矢誰也沒殺,就TM來打醬油的。。。
    posted @ 2011-10-21 14:29 Jcat 閱讀(575) | 評論 (1)編輯 收藏
    簡單過一遍,詳細(xì)的以后遇到慢慢研究。
    主要的更新在幾個方面:
    1. OUI的改進(jìn)
    2. Oracle Restart
    3. ASM的增強(qiáng)!!!


    New Grid Infrastructure Installation Option
    ?1. 單點(diǎn)包括:ASM、listener和Oracle Restart(監(jiān)控、管理并自動重啟各個組件)
    ?2. 集群包括:ASM、listener和Clusterware

    New Desktop and Server Class Options
    ?1. Desktop Class:適用于筆記本、臺式機(jī)
    ?2. Server Class:適用于服務(wù)器(功能上沒區(qū)別,多一些高級配置選項)

    Daylight Savings Time Upgrade of Timestamp with Timezone Data Type
    ?新的DBMS_DST包,優(yōu)化對TIMESTAMP WITH TIMEZONE數(shù)據(jù)的管理

    SYSASM Privilege
    ?管理ASM需要SYSASM權(quán)限,旨在分清ASM管理和DB管理

    Fixup Scripts and Prerequisite Checks
    ?安裝前檢查時,如果遇到不符合要求的配置,OUI會對一些檢查項自動生成fixup腳本,用root執(zhí)行就可以解決相應(yīng)問題。

    New Tool to Configure Custom Installation Options
    ?OUI不在提供對單個組件的配置功能,如果需要只能用$ORACLE_HOME/bin/chopt命令行進(jìn)行配置。我想Oracle的趨勢就是為了讓更多已經(jīng)成熟的配置自動化,簡化使用。

    Deinstallation Tool
    ?OUI不再用來刪除oracle軟件,請使用$ORACLE_HOME/deinstall

    Intelligent Data Placement
    ?指定ASM磁盤的磁盤范圍,旨在將高頻訪問的數(shù)據(jù)放在HOT region(比如磁盤的外道)

    Oracle Automatic Storage Management Cluster File System (Oracle ACFS)
    ?為其它文件提供ASM的存儲功能

    Data Pump Export and Data Pump Import
    ?Data Pump兼容Export/Import

    Use Oracle Restart to Automatically Restart Your Database

    ?1. 針對單點(diǎn)環(huán)境
    ?2. 自動重啟又問題的組件,如:db instance、listener、asm instance

    New Method of Installing Oracle Automatic Storage Management
    ?以前,ASM的安裝是伴隨著DB的安裝;現(xiàn)在是伴隨著Software的安裝。
    ?其實,就是把ASM上升到一個軟件的高度(以前只是db的一個組件)

    SRVCTL Support for Single Instance Database in a Cluster
    ?SRVCTL統(tǒng)一管理單點(diǎn)(with Restart)和集群數(shù)據(jù)庫(with Clusterware)

    Deprecated in Oracle Database 11g Release 2
    ?不支持裸設(shè)備了:要么用文件系統(tǒng)、要么用ASM,說白了,企業(yè)環(huán)境就必須用ASM
    ?不支持Oracle Ultra Search(9i的一個什么鳥功能)






















    posted @ 2011-06-17 15:35 Jcat 閱讀(826) | 評論 (0)編輯 收藏
    重裝完系統(tǒng),mysql不需要重裝,直接當(dāng)綠色版使用,還更干凈

    //啟動MYSQL
    cd $MYSQL_HOME/bin
    D:\JAVA\MYSQL\mysql-5.1.53-win32\bin>mysqld --console??????
    110616? 1:26:26 [Note] Plugin 'FEDERATED' is disabled.
    InnoDB: The log sequence number in ibdata files does not match
    InnoDB: the log sequence number in the ib_logfiles!
    110616? 1:26:26? InnoDB: Database was not shut down normally!
    InnoDB: Starting crash recovery.
    InnoDB: Reading tablespace information from the .ibd files...
    InnoDB: Restoring possible half-written data pages from the doublewrite
    InnoDB: buffer...
    110616? 1:26:26? InnoDB: Started; log sequence number 0 44233
    110616? 1:26:27 [Note] Event Scheduler: Loaded 0 events
    110616? 1:26:27 [Note] mysqld: ready for connections.
    Version: '5.1.53-community'? socket: ''? port: 3306? MySQL Community Server (GPL
    )

    //簡單使用

    mysql> show databases;
    +--------------------+
    | Database?????????? |
    +--------------------+
    | information_schema |
    | mysql????????????? |
    | test?????????????? |
    +--------------------+
    3 rows in set (0.03 sec)

    mysql> use mysql
    Database changed

    mysql> show tables;
    +---------------------------+
    | Tables_in_mysql?????????? |
    +---------------------------+
    | columns_priv????????????? |
    | db??????????????????????? |
    | event???????????????????? |
    | func????????????????????? |
    | general_log?????????????? |
    | help_category???????????? |
    | help_keyword????????????? |
    | help_relation???????????? |
    | help_topic??????????????? |
    | host????????????????????? |
    | ndb_binlog_index????????? |


    登陸
    D:\JAVA\MYSQL\mysql-5.1.53-win32\bin>mysql.exe -uroot
    創(chuàng)建數(shù)據(jù)庫
    mysql> create database testdb;




    posted @ 2011-06-16 01:40 Jcat 閱讀(945) | 評論 (1)編輯 收藏
    --主鍵是非分區(qū)索引,也可以看作是全局
    create table test_par1
    (
    ? tdate?? varchar2(8) primary key
    )
    partition by range ( tdate )
    (
    ???? partition p1 values less than ('20090201'),
    ???? partition p2 values less than ('20090301'),
    ???? partition pm values less than (MAXVALUE) ?
    ) tablespace test;


    --主鍵是分區(qū)索引
    create table test_par2
    (
    ? tdate?? varchar2(8)
    )
    partition by range ( tdate )
    (
    ???? partition p1 values less than ('20090201'),
    ???? partition p2 values less than ('20090301'),
    ???? partition pm values less than (MAXVALUE) ?
    ) tablespace test;

    create index i_tdate2 on test_par2(tdate) local;

    alter table test_par2 add constraint pk_tdate2 primary key(tdate);



    --查看test_par2的DDL
    select dbms_metadata.get_ddl( 'TABLE', 'TEST_PAR2' ) from dual;
    --整理如下
    create table test_par3
    (
    ? tdate?? varchar2(8),
    ? constraint pk_tdate3 primary key (tdate) using index local
    )
    partition by range ( tdate )
    (
    ???? partition p1 values less than ('20090201'),
    ???? partition p2 values less than ('20090301'),
    ???? partition pm values less than (MAXVALUE) ?
    ) tablespace test;


    這個案例也告訴我們,在做DDL時,盡量還是顯示的寫出屬性,一些簡易語法會引起不可知的定義。最后都用 get_ddl 再查一下,這才是Oracle真正執(zhí)行的DDL。
    posted @ 2010-09-15 15:26 Jcat 閱讀(1292) | 評論 (0)編輯 收藏
    列出所有實例
    [db2inst1@dcm ~]$ db2ilist
    db2inst1

    列出當(dāng)前實例下的所有數(shù)據(jù)庫

    [db2inst1@dcm ~]$ db2 list db directory

    ?System Database Directory

    ?Number of entries in the directory = 1

    Database 1 entry:

    ?Database alias?????????????????????? = SAMPLE
    ?Database name??????????????????????? = SAMPLE
    ?Local database directory???????????? = /home/db2inst1
    ?Database release level?????????????? = d.00
    ?Comment????????????????????????????? =
    ?Directory entry type???????????????? = Indirect
    ?Catalog database partition number??? = 0
    ?Alternate server hostname??????????? =
    ?Alternate server port number???????? =

    啟動實例
    [db2inst1@dcm ~]$ db2start
    07/09/2010 14:24:36???? 0?? 0?? SQL1063N? DB2START processing was successful.
    SQL1063N? DB2START processing was successful.

    連接到數(shù)據(jù)庫
    [db2inst1@dcm ~]$ db2 connect to sample

    ?? Database Connection Information

    ?Database server??????? = DB2/LINUX 9.7.1
    ?SQL authorization ID?? = DB2INST1
    ?Local database alias?? = SAMPLE

    執(zhí)行SQL
    [db2inst1@dcm ~]$ db2
    db2 => select * from staff where dept=20

    ID???? NAME????? DEPT?? JOB?? YEARS? SALARY??? COMM??? ?
    ------ --------- ------ ----- ------ --------- ---------
    ??? 10 Sanders?????? 20 Mgr??????? 7? 98357.50???????? -
    ??? 20 Pernal??????? 20 Sales????? 8? 78171.25??? 612.45
    ??? 80 James???????? 20 Clerk????? -? 43504.60??? 128.20
    ?? 190 Sneider?????? 20 Clerk????? 8? 34252.75??? 126.50

    ? 4 record(s) selected.

    退出
    db2 => quit
    DB20000I? The QUIT command completed successfully.

    斷開連接(不斷開就不能db2stop)
    [db2inst1@dcm ~]$ db2 connect reset
    DB20000I? The SQL command completed successfully.

    關(guān)閉實例
    [db2inst1@dcm ~]$ db2stop
    07/09/2010 14:29:32???? 0?? 0?? SQL1064N? DB2STOP processing was successful.
    SQL1064N? DB2STOP processing was successful.

    posted @ 2010-07-09 14:32 Jcat 閱讀(262) | 評論 (0)編輯 收藏
    最近初探了一下DB2,發(fā)現(xiàn)關(guān)于“數(shù)據(jù)庫”、“實例”的概念及其關(guān)系容易把人弄暈,這里小小總結(jié)一下,并把Oracle也拉進(jìn)來一起整。
    另外,發(fā)現(xiàn)Oracle和IBM老搞一些理論上就針鋒相對的事情,如RAC vs DPF (database partitioning feature),很是有趣。



    基本概念還是相同的
    數(shù)據(jù)庫軟件(下面簡稱軟件:軟件本身,一臺主機(jī)安裝一套就可以了。(拋開你故意在一臺服務(wù)器上安裝2遍Oracle/DB2這種不正常思維)

    實例:數(shù)據(jù)庫軟件啟動后的“進(jìn)程+內(nèi)存”
    軟件+實例的關(guān)系:一臺電腦只需要按照一套QQ(軟件),但是我們可以多用戶登錄(實例)。換到哲學(xué)的角度,就是抽象和具體的關(guān)系。
    數(shù)據(jù)庫(狹義,下面簡稱:一堆文件(數(shù)據(jù)文件、控制文件、日志文件、參數(shù)文件)
    它和軟件的區(qū)別:軟件是廠商賣給你的東西;是你自己的東西(業(yè)務(wù)、應(yīng)用)
    它和實例的關(guān)系:用戶需要借助實例(所提供的各種手段)來訪問
    就相當(dāng)于是QQ聊天記錄

    最后:數(shù)據(jù)庫(廣義)= 軟件 + 實例 + 庫
    一臺服務(wù)器(即一套數(shù)據(jù)庫軟件)可以建多個實例,多個庫,且互不相干


    體系結(jié)構(gòu)的不同之處
    Oracle? 實例和庫一一對應(yīng)
    DB2???? 一個實例可以掛多個庫


    高級情況(簡單提一下,以后再慢慢研究)
    Oracle:RAC一個庫被多個實例掛
    DB2:DPF一個實例多個庫
    在數(shù)據(jù)庫集群模式設(shè)計方面,有Share everything架構(gòu)和Share nothing架構(gòu),前者以O(shè)RACLE RAC為代表,IBM DB2 Purescale為挑戰(zhàn)者;后者以IBM DB2 DPF為代表。

    posted @ 2010-07-08 18:26 Jcat 閱讀(436) | 評論 (0)編輯 收藏
    行鏈接:
    1. 一條記錄的大小大于block size,則產(chǎn)生行鏈接
    2. 容易發(fā)生在比較大的行上
    3. 因為行鏈接是由db_block_size不夠大引起的,所以對已有的行鏈接是無法清除的
    4. 9i以后,可以對不同的表空間設(shè)置不同的db_block_size,可以將一些特殊的寬表放在大block size的表空間

    例子:
    表空間block size為8k(8192),因為數(shù)據(jù)塊頭也要占一定空間,所以如下例,實際只能放7948的數(shù)據(jù),一旦超過,就產(chǎn)生行鏈接

    --無
    create table test7948(a char(2000),b char(2000),c char(2000),d char(1948))
    tablespace test;

    insert into test7948 values('a','b','c','d');
    commit;

    --有
    create table test7949(a char(2000),b char(2000),c char(2000),d char(1949))
    tablespace test;

    insert into test7949 values('a','b','c','d');
    commit;



    行遷移:
    1. 本來是放的下的
    2. 因為更新使row size變大了,一個block里又不足以放下增加的空間(PCTFREE相關(guān)),則產(chǎn)生行遷移
    3. 容易發(fā)生在PCTFREE較小,對類似varchar類型的update又很多的表上
    4. 無法避免,但通過把數(shù)據(jù)導(dǎo)出導(dǎo)入進(jìn)行清除

    例子:
    --無
    create table test7948_vchar(a char(2000),b char(2000),c char(2000),d char(1940), e varchar(9))
    tablespace test;

    insert into test7948_vchar values('a','b','c','d','12345678');
    commit;

    一更新,使得row size大于7948了,產(chǎn)生行遷移
    --有
    update test7948_vchar set e='123456789'
    posted @ 2010-06-13 14:08 Jcat 閱讀(242) | 評論 (0)編輯 收藏
    隨著Oracle收購SUN,今天又爆出SAP收購Sybase的大料。

    現(xiàn)狀:
    Oracle和IBM已經(jīng)成為諾亞方舟級的廠商,啥都有。
    微軟,SAP成為航母級的廠商,軟件方面啥都有,但目前沒有硬件。

    猜想:who's next? Dell? HP?
    不然微軟把Dell收了吧,組成BDll公司;
    然后SAP和HP合并為SHP
    posted @ 2010-05-14 11:24 Jcat 閱讀(248) | 評論 (0)編輯 收藏
    --創(chuàng)建一個大一點(diǎn)的TEMP表空間
    create temporary tablespace temp1
    tempfile '/oracledatafile/temp01.dbf' SIZE 100m autoextend on next 100m maxsize 5000m;
    ?
    --切換默認(rèn)TEMP表空間
    alter database default temporary tablespace temp1;

    --刪掉以前的TEMP表空間
    drop tablespace temp including contents and datafiles;
    posted @ 2010-04-30 11:05 Jcat 閱讀(292) | 評論 (0)編輯 收藏
    1. 物化視圖由于是物理真實存在的,故可以創(chuàng)建索引。




    --為基表創(chuàng)建MLOG
    --創(chuàng)建物化視圖時應(yīng)先創(chuàng)建存儲的日志空間,否則建MV時報錯
    --ORA-23413: table "SCOTT"."EMP" does not have a materialized view log

    create materialized view log on scott.emp
    tablespace test
    /


    --創(chuàng)建物化視圖
    create materialized view test_mv
    tablespace test
    parallel (degree 4)
    build immediate refresh fast
    enable query rewrite
    as
    select * from scott.emp
    /


    --查看一下結(jié)果,果然很符合物化視圖的定義,一個表+一個視圖
    SQL> select object_name, object_type from user_objects where object_name = 'TEST_MV';
    OBJECT_NAME??? OBJECT_TYPE
    -----------??? --------
    TEST_MV??? ??? TABLE
    TEST_MV??? ??? MATERIALIZED VIEW

    SQL> select mview_name, container_name from user_mviews;
    MVIEW_NAME?????? CONTAINER_NAME
    ---------------- ------------------------------
    TEST_MV????????? TEST_MV? (這就是那個存儲表)

    --查看MLOG的情況
    --注意:MLOG的所屬和MV的所屬并不是同一個
    SQL> select log_owner, master, log_table from dba_mview_logs
    LOG_OWNER??? MASTER??? LOG_TABLE
    ---------------------------------
    SCOTT??? ??? EMP??? MLOG$_EMP (MLOG其實也就是一個表)

    SQL> desc scott.mlog$_emp;
    Name??? ??? ??? Type
    -------------------------------
    EMPNO??? ??? ??? NUMBER(4)
    SNAPTIME$$??? ??? DATE
    DMLTYPE$$??? ??? VARCHAR2(1)
    OLD_NEW$$??? ??? VARCHAR2(1)
    CHANGE_VECTOR$$??? ??? RAW(255)



    --刪除MLOG
    drop materialized view log on 物化視圖所依賴的表名;?
    --刪除物化視圖
    drop materialized view 物化視圖名;
    posted @ 2010-01-13 00:04 Jcat 閱讀(547) | 評論 (2)編輯 收藏
    注意,為了能在終端看見put_line的輸出,還需要先開啟
    set serveroutput on

    ?

    --用來測試的表
    create table test_tri(
    a1 int,
    a2 int
    )
    tablespace test


    -----行級insert觸發(fā)器
    -----
    1) 插入的一行新數(shù)據(jù)保存在:new
    2)
    insert觸發(fā)器沒有:old值
    3) 對:new的修改,只能定義在before類型的觸發(fā)器中

    ---觸發(fā)器語法---
    create or replace trigger 名稱
    [after|before] [delete|update|insert]
    [of 列名] [on 表名]
    [referencing new as 新行別名 old as 舊行別名]
    [for each row] [when(條件)]
    declare
    ....
    begin
    ...
    exception
    ....
    end;


    --定義
    create or replace trigger test_before_insert
    before insert on test_tri
    for each row when(new.a2 is null)
    begin
    ?? ?dbms_output.put_line('insert row original: a1=' || :new.a1 || ' a2=' || :new.a2);
    ?? ?:new.a2 := :new.a1 * 2;? ?
    end;
    /

    create or replace trigger test_after_insert
    after insert on test_tri
    for each row
    begin
    ?? ?dbms_output.put_line('insert row actual: a1=' || :new.a1 || ' a2=' || :new.a2);? ?
    end;
    /

    --測試

    SQL> insert into test_tri(a1) values(1);
    insert row original: a1=1 a2=
    insert row actual: a1=1 a2=2

    SQL> insert into test_tri values(2,3);
    insert row actual: a1=2 a2=3

    SQL> select * from test_tri;
    ??????? A1???????? A2
    ---------- ----------
    ???????? 1????????? 2(由觸發(fā)器生成的值)
    ???????? 2????????? 3



    -----DDL觸發(fā)器-----
    --任何create語句都會觸發(fā)這個語句

    create or replace trigger test_ddl_trigger
    before create on schema
    begin
    ??? dbms_output.put_line( 'DDL Trigger' );
    ??? insert into test_tri values(9,9);
    end;
    posted @ 2010-01-11 14:58 Jcat 閱讀(270) | 評論 (0)編輯 收藏
    Oracle建好后,tnsnames和listener中自動就帶有如下內(nèi)容,這里咱們就來解釋一下這些東西是干什么用的

    ----TNSNAMES.ora----
    EXTPROC_CONNECTION_DATA =
    ? (DESCRIPTION =
    ??? (ADDRESS_LIST =
    ????? (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    ??? )
    ??? (CONNECT_DATA =
    ????? (SID = PLSExtProc)
    ????? (PRESENTATION = RO)
    ??? )
    ? )

    ----LISTENER.ora----
    SID_LIST_LISTENER =
    ? (SID_LIST =
    ??? (SID_DESC =
    ????? (SID_NAME = PLSExtProc)
    ????? (ORACLE_HOME = /opt/oracle/10gR2)
    ????? (PROGRAM = extproc)
    ??? )
    ? )

    LISTENER =
    ? (DESCRIPTION_LIST =
    ??? (DESCRIPTION =
    ????? (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    ????? (ADDRESS = (PROTOCOL = TCP)(HOST = dcm)(PORT = 1521))
    ??? )
    ? )


    IPC - Inner Process Communication
    When a process is on the same machine as the server, use the IPC protocol for connectivity instead of TCP. Inner Process Communication on the same machine does not have the overhead of packet building and deciphering that TCP has.
    I've seen a SQL job that runs in 10 minutes using TCP on a local machine run as fast as one minute using an IPC connection. The difference in time is most dramatic when the Oracle process has to send and/or receive large amounts of data to and from the database.
    For example, a SQL*Plus connection that counts the number of rows of some tables will run about the same amount of time, whether the database connection is made via IPC or TCP. But if the SQL*Plus connection spools much data to a file, the IPC connection will often be much faster -- depending on the data transmitted and the machine workload on the TCP stack.

    For how to configure it:
    1. you should add one IPC line in the LISTENER.ORA
    2. You should also add one IPC line in the TNSNAMES.ORA



    PLSExtPro - PL/Sql External Procdure
    默認(rèn)安裝時,會安裝一個PL/SQL外部程序(extproc--這是程序名)條目在listener.ora中,是oracle為調(diào)用外部程序默認(rèn)配置的監(jiān)聽,它的名字(也就是SID)通常是ExtProc或PLSExtProc
    但一般不會使用它,可以直接從listener.ora中將這項移除,因為對ExtProc已經(jīng)有多種攻擊手段了,在不使用外部程序時,Oracle也是建議刪除的。



    extproc的作用
    就是在pl/sql中調(diào)用外部語句,如c,java寫的過程。
    現(xiàn)在,Oracle已經(jīng)全面支持JAVA了,這東西也就過時了,之所以繼續(xù)保留是考慮到兼容以前老版本的數(shù)據(jù)庫實例。

    [oracle@dcm bin]$ extproc
    Oracle Corporation --- TUESDAY?? JAN 05 2010 21:58:23.878
    Heterogeneous Agent Release 10.2.0.1.0 - Production

    posted @ 2010-01-05 21:59 Jcat 閱讀(660) | 評論 (0)編輯 收藏
    --登錄sys用戶,創(chuàng)建一個測試用戶,權(quán)限可以給大點(diǎn)
    SQL> create user test identified by xxxxx;
    SQL> grant connect to test;
    SQL> grant resource to test;
    SQL> grant dba to test;


    --登錄test用戶,開始測試
    --建個測試表
    create table test_table(id int, time timestamp);

    --創(chuàng)建Job
    begin
    dbms_scheduler.create_job(
    ?? ?job_name => 'test_job',
    ?? ?job_type => 'PLSQL_BLOCK',
    ?? ?job_action => 'insert into test_table
    ????????????????? (select nvl(max(id),0)+1, systimestamp from test_table, dual);', --nvl函數(shù)同SQLServer的isnull函數(shù)
    ?? ?start_date => null, --一激活,就開始
    ?? ?repeat_interval => 'FREQ=SECONDLY;INTERVAL=10');
    end;

    FREQ用來指定間隔的時間周期,可選參數(shù)有:YEARLY,MONTHLY,WEEKLY,DAILY,HOURLY,MINUTELY,SECONDLY。

    --光創(chuàng)建沒用,還需要激活;也可以在創(chuàng)建時,直接把enable屬性設(shè)置為true(enabled => true
    select job_name, enabled, run_count from user_scheduler_jobs;
    JOB_NAME?????????????????????? ENABL? RUN_COUNT
    ------------------------------ ----- ----------
    TEST_JOB?????????????????????? FALSE????????? 0


    begin
    dbms_scheduler.enable('test_job');
    end;

    --查看效果
    select id, to_char(time,'HH24:MI:SS:FF3') from test_table;
    ?????? ID? TO_CHAR(TIME,'HH24
    ---------- ------------------
    ???????? 1 16:13:29:542
    ???????? 2 16:13:39:506
    ???????? 3 16:13:49:109
    ???????? 4 16:13:59:097
    ???????? 5 16:14:09:109
    ???????? 6 16:14:19:103
    ???????? 7 16:14:29:101
    ???????? 8 16:14:39:099
    ???????? 9 16:14:49:105
    ??????? 10 16:14:59:100


    --停止任務(wù)
    begin
    dbms_scheduler.disable('test_job');
    end;

    --刪除任務(wù)
    begin
    dbms_scheduler.drop_job('test_job');
    end;
    posted @ 2009-12-17 16:13 Jcat 閱讀(257) | 評論 (0)編輯 收藏

    一致和并發(fā)是對立的,需要根據(jù)應(yīng)用,選擇權(quán)宜之計


    數(shù)據(jù)不一致的現(xiàn)象

    ---事務(wù)內(nèi)單SQL的情況---
    1.臟讀-Dirty Read:本事務(wù)讀取了其它事務(wù)尚未提交的修改數(shù)據(jù)
    例子:讀了不該讀的
    1:00 x=1
    1:01 A用戶 Update x=2(但未commit)
    1:02 B用戶 Select x --> x=2
    合理的情況是x仍然等于1

    ---事務(wù)內(nèi)多SQL的情況(典型的如,先查再改)---
    2.不可重復(fù)讀-Non Repeatable Read
    例子1:自相矛盾
    1:00 x=1 y=2
    1:01 B用戶 Select x,y --> x=1 y=2
    1:02 A用戶 Update x=2; Commit;
    1:03 B用戶 Select x+y --> x+y=4
    首先這個結(jié)果從單條SQL的角度看,是沒有問題的。但是,如果把B的兩次查詢看作一個整體(事務(wù)),那么合理的情況應(yīng)該是
    ? x+y仍然等于3
    ? 或者B再進(jìn)行一次事務(wù),得出 x=2 y=2 x+y=4 的結(jié)果


    例子2:更新丟失
    1:00 x=1
    1:01 B用戶 Select x --> x=1
    1:02 A用戶 Select x --> x=1
    1:03 A用戶 Update x=2; Commit;
    1:04 B用戶 Update x=3; Commit;
    同樣,從單條SQL來講,沒有任何問題。
    但是從邏輯的合理性講,一般的更新操作都是先查再改,換言之
    ? A真正想做的是Update x from 1 to 2
    ? B真正想做的是Update x from 1 to 3
    但最終卻造成了在B不知情的情況下,把B的初衷改為了Update x from 2 to 3


    3.幻影讀-Phantom Read
    例子:讀到了未來
    1:00 X1=1 X2=2
    1:01 B用戶 Select Xi --> X1=1 X2=2
    1:02 A用戶 Insert X3=3; Commit;
    1:03 B用戶 Select sum(Xi) --> re=6
    其實道理和之前的不可重復(fù)讀相同,只不過是由Insert引起的罷了。
    (甚至Delete也會引起類似的問題,但好像學(xué)術(shù)界并沒有對Delete進(jìn)行討論)




    Isolation Level
    Read Uncommitted:1,2,3都會發(fā)生
    ? Oracle中嚴(yán)格禁止臟讀
    ? 在SQL Server 7.0中,是可以選擇該級別的
    Read Committed:發(fā)生2,3(Oracle的默認(rèn)級別)
    Repeatable Read:發(fā)生3
    Serializable:都不發(fā)生


    Oracle的實現(xiàn)方式
    Read Committed:默認(rèn)就實現(xiàn)
    Repeatable Read:
    ? 1. 悲觀鎖(select ... for update),影響并發(fā)
    ? 2. 樂觀鎖(update where 所有字段都作為條件),不影響并發(fā)
    Serializable:
    ? alter session set isolation_level=serializable/read only
    posted @ 2009-12-05 17:45 Jcat 閱讀(227) | 評論 (0)編輯 收藏
    主站蜘蛛池模板: 国产传媒在线观看视频免费观看| 国产精品偷伦视频观看免费 | 国产在线ts人妖免费视频| 亚洲午夜久久影院| 人妻无码一区二区三区免费| 色噜噜亚洲精品中文字幕 | 亚洲国产精品免费在线观看| 免费A级毛片av无码| 亚洲第一页中文字幕| 57pao一国产成永久免费| 日韩精品一区二区亚洲AV观看 | 国产精品免费在线播放| 亚洲精品美女久久777777| 久久www免费人成看国产片| 亚洲人成人77777网站| 美女视频黄的免费视频网页| 亚洲AV无码成人专区片在线观看 | 亚洲一级特黄特黄的大片| 国产成在线观看免费视频| 亚洲va在线va天堂va手机| 成人免费看片又大又黄| 狠狠入ady亚洲精品| 亚洲成人影院在线观看| 二个人看的www免费视频| 亚洲综合一区二区精品导航 | 日韩视频免费在线观看| 亚洲视频中文字幕在线| 在线精品免费视频无码的| 老司机午夜在线视频免费| 在线A亚洲老鸭窝天堂| 1000部拍拍拍18勿入免费视频下载 | www.亚洲色图| 三年片免费观看大全国语| 亚洲美女人黄网成人女| 日韩一级视频免费观看| 一级毛片免费观看不收费| 亚洲国产女人aaa毛片在线| 特级做A爰片毛片免费69| 免费精品久久久久久中文字幕| 亚洲国产一二三精品无码| 无码少妇一区二区浪潮免费|