å®ä¾åæ°æ®åºçå
³ç³»
å®ä¾æ¯è¿è¡å¨å
åä¸çä¸ç³»åè¿ç¨ï¼ç¨äºç¸åºå®¢æ·ç«¯è¯·æ±ï¼å¨å
åä¸ç¼åæ°æ®ä»¥åä¸æ°æ®åºäº¤äºççãèæ°æ®åºæ¯å®é
åå¨æ°æ®çç»ç»ã
Oracleä¸ä¸ä¸ªå®ä¾åªè½å¯¹åºä¸ä¸ªæ°æ®åºï¼æå¤ä¸ªå®ä¾å¯¹åºä¸ä¸ªæ°æ®åºï¼è¿ç§æ¶æ称为RAC--Real Application Clusterã对äºæ¯ä¸ªå®ä¾ï¼æä¸ä¸ªSID(System ID)æ¥å¯ä¸æ è¯ï¼å¨è¿æ¥å°æ°æ®åºæå¡å¨æ¶éè¦æä¾(æè
æä¾service nameä¹å¯ä»¥)ãå
³äºSIDåService nameçåºå«å¯èªè¡æç´¢ã
SQL Serverä¸ä¸ä¸ªå®ä¾å¯ä»¥å¯¹åºå¤ä¸ªæ°æ®åºï¼åæ¶ä¸å°æºå¨å¯ä»¥æç
§å¤ä¸ªå®ä¾ãç±äºåä¸å°æºå¨ä¸çå¤ä¸ªå®ä¾éè¦äºç¸åºåï¼å æ¤å¦æä»
å®è£
ä¸ä¸ªå®ä¾å使ç¨é»è®¤å®ä¾ï¼å¦æå®è£
å¤ä¸ªå®ä¾ï¼åéè¦ä½¿ç¨å½åå®ä¾ã
æ°æ®åå¨ç»æ
Oracleä¸ï¼å
³äºåå¨çé»è¾æ¦å¿µæï¼
block--ç±å¤ä¸ªIO blocksç»æï¼ä¸è¬ä¸º4æ8KB
extent--ä¸æ®µè¿ç»çblocksï¼ç¨äºåå¨ç¹å®çä¿¡æ¯
segment--ç±ä¸ç³»åçextentsææï¼ç¨äºåå¨ç¹å®çæ°æ®åºå¯¹è±¡ï¼ä¾å¦è¡¨ãæ¯ä¸ªæ°æ®åºå¯¹è±¡é½åå¨å¨åç¬çsegmentä¸ãéè¦æ³¨æçæ¯segmentå¯ä»¥è·¨å¤ä¸ªdata fileã
tablespace -- ä¸ä¸ªæ°æ®åºæ两个tablespaceï¼ System tablespace & Data tablespaceãæ¯ä¸ªtablespaceå¯æå¤ä¸ªdata fileï¼ä½data fileä¸å¯è·¨tablespaceï¼ä¹ä¸å¯è·¨ç£çã
å
³äºåå¨çç©çç»ææï¼
iOS block--æç£çå±é¢çæå°è¯»ååå
data file--æ°æ®æ件ï¼å¨ioså±é¢å¯å®é
è§å¯å°çæ件
å
·ä½è¯·åèï¼
http://docs.oracle.com/cd/E11882_01/server.112/e40540/logical.htm#CNCPT301SQL Serverä¸åå¨çé»è¾æ¦å¿µæï¼
data page--SQL Serveråå¨æ°æ®çæå°åå
ï¼å¤§å°ä¸º8KBã
extent--8个data pagesææä¸ä¸ªextentï¼å æ¤ä¸ä¸ªextentç大å°ä¸º64KBãextentåå为两ç§ï¼uniform and mixedãé常ä¸ä¸ªæ°æ®åºå¯¹è±¡ç±å¤ä¸ªuniform extentææï¼ä½å½å¯¹è±¡è¶³å¤å°çæ¶åï¼ä¹å¯ä»¥ç±å¤ä¸ªå¯¹è±¡å
±ç¨å¤ä¸ªmixed extentsã
请åèï¼
https://technet.microsoft.com/en-us/library/ms190969(v=sql.105).aspx
ç©çç»æä¸ç±æ件åæ件ç»ææï¼è¯·åèï¼
https://technet.microsoft.com/en-us/library/ms179316(v=sql.105).aspx
Schema
OracleåSQL Serverä¸schemaçæ¦å¿µæ¯ç±»ä¼¼çã
表
Oracleä¸æå¤ç§å¤æ ·ç表ï¼
Ordinary table--å°±æ¯å个å
³ç³»åæ°æ®åºä¸é½å¯å®ä¹ç表ã
Object table -- Oracleä¸å¯ä»¥å®ä¹å¯¹è±¡ç±»åï¼æ¯ä¸ªå¯¹è±¡ç±»åå¯ä»¥å
å«æååéï¼æåæ¹æ³ãèobject tableæ¯ä¸ç±»ç¹æ®ç表ï¼å
¶ä¸æ¯è¡æ°æ®é½æ¯ä¸ä¸ªå¯¹è±¡ãæ¯è¡å¯ä»¥ç¨OIDæ¥å¯ä¸æ è¯ã
Heap-organized table -- æ表ä¸çæ°æ®æ²¡æä»»ä½é¡ºåºç表ã
Index-organized table -- An index-organized table orders rows according to the primary key values. ä½SQL Serverä¸ç¨clustered-indexæ¥å¯¹è¡¨æ°æ®æåºã注æå®ä¹primary key并ä¸ä¼è®©è¡¨æ为index-organized tableï¼è¿éè¦æå®ORGANIZATION INDEXå
³é®åã
External table -- æå¨Oracleä¸ä»
åå¨äºå
æ°æ®ï¼èæ°æ®æ¬èº«åä¸åæ°æ®åºä¹å
ãä¾å¦çæ£çæ°æ®å¯è½æ¯ä¸ä¸ªtxtæ件ã
Temporary table--Oracleä¸ç临æ¶è¡¨æ¯æ°¸ä¹
æ§çï¼å³ç¨æ·å建临æ¶è¡¨åï¼è¯¥è¡¨å°±ä¼åå¨äºç¨æ·schemaä¸ãä½è¡¨ä¸çæ°æ®ä¼éçç¨æ·æå¼session被å é¤æéçäºå¡çç»æ被å é¤ã
Table Clusters--A table cluster is a group of tables that share common columns and store related data in the same blocks.
Hash Clusters--
å¯åçä¸ä¾é¾æ¥ï¼
http://docs.oracle.com/cd/E11882_01/server.112/e40540/tablecls.htm#CNCPT1859SQL Serverï¼
Ordinary table--åä¸
heap table -- æ没æ建ç«ä»»ä½ç´¢å¼ç表
non-heap table -- æ建ç«äºç´¢å¼ç表ãSQL Serverä¸éè¿å建clustered indexæ¥å¯¹è¡¨çç©çæ°æ®æåºï¼ä¸ææ¯èéç´¢å¼ã注æåOracleçtable clustersæ¯å®å
¨ä¸åçä¸è¥¿ã
Temporary table -- å¨TSQLä¸å¯ä»¥å®ä¹ä¸´æ¶è¡¨ï¼ç¨äºåå¨è®¡ç®ä¸é´ç»æï¼å¦DECLARE #t_table TABLE (XXX)ã临æ¶è¡¨çæ°æ®å¨ç¡¬çä¸ï¼å±äºtempæ°æ®åºãå½ç¨æ·sessionæå¼æ¶ï¼ä¸´æ¶è¡¨è¢«dropæãå¦å¤SQL Serverè¿æä¾è¡¨åéï¼ç¨äºå¨å
åä¸åå¨ä¸é´ç»æï¼å¦DECLARE @t_table TABLE (XXX)ã
external table -- SQL Serverä¸çå¤é¨è¡¨åOracleçå¤é¨è¡¨æ¯ç±»ä¼¼çï¼ä½SQL Serverçå¤é¨è¡¨ä»
ç¨äºæ¥è¯¢Hadoop clusteræAmazon cloudä¸çæ°æ®ã
è§å¾
Oracleä¸çè§å¾æï¼
View -- å¯ä»¥è¢«çåä¸ä¸ªä¿åäºçqueryï¼èä¸æ¯ä¸ä¸ªå®é
ç表ãä½åviewæ§è¡DMLä¼å¼èµ·åºå±ç表æ°æ®åçååã
Object view -- æ®éçviewæ¯åºäºæ®é表ï¼èobject viewåæ¯åºäºobject tableã
Materialized Views -- ç©åè§å¾ï¼å³è§å¾ä¸åæ¯ä¸ä¸ªqueryï¼èæ¯ä¸ä¸ªçå®ç表ãç±å®ä¹å¯ç¥å½åºè¡¨çæ°æ®ååæ¶ï¼å¿
ç¶éè¦å°æ°æ®åæ¥å°ç©åè§å¾ï¼ä¸å¿
ç¶æ¯å¼æ¥çãoracleçç©åè§å¾å¯ä»¥éæ©æ¯å¢éæ´æ°è¿æ¯å®å
¨æ´æ°æ¹å¼ãå¦å¤åªè½å¨ç©åè§å¾ä¸å建索å¼ï¼æ®éè§å¾ä¸å¯ä»¥ã
SQL Serverä¸çè§å¾ææ®éè§å¾åç©åè§å¾ãå½å¨ä¸ä¸ªæ®éè§å¾ä¸å建indexæ¶ï¼è¯¥è§å¾å°±æ为äºç©åè§å¾ã
ç´¢å¼
Oracleä¸æ两ç§ç»æçç´¢å¼ï¼B-treeç´¢å¼åbitmapç´¢å¼ãB-treeç´¢å¼ä¸ºé»è®¤ä½¿ç¨çç´¢å¼ï¼bitmapç´¢å¼å¨æäºç¹æ®æ
åµä¸å¯æé«æ¥è¯¢æçã
SQL Serverä»
æ¯æB-treeç´¢å¼ã
ROWIDåRID
Oracleä¸æ¯ä¸ªè¡¨é½ä¼æä¸ä¸ªä¼ªå(pseudo column)ï¼ç§°ä¸ºROWIDãROWIDç±18ä½å符ç»æï¼å¯å¯ä¸å®ä½çæ¯ä¸è¡æ°æ®ãå
¶å½¢å¼ä¸ºï¼
object_number(6ä½):file_number(3ä½):block_number(6ä½):row_number(3ä½)
å¨Oracleä¸ï¼ROWID Seekæ¯ä¸ä¸è¾é«æçå®ä½æ°æ®çæ¹å¼ã
SQL Serverä¸åä¸æä¾ROWIDãä¸ä¹ææ¥è¿çæ¯RIDï¼å
¶å½¢å¼ä¸ºï¼
File:Page:Slot
SQL Serverä»
å¨å¯¹heap表æ¥è¯¢æ¶æä¼ä½¿ç¨RIDå®ä½æ°æ®ãå¨å»ºç«äºèéç´¢å¼ç表ä¸ï¼ç±äºç´¢å¼ç页级èç¹å°±æ¯è¡¨æ¬èº«ï¼å æ¤ä¸éè¦ä½¿ç¨RIDæ¥å®ä½æ°æ®ã
Joinç®æ³
å½æ¶åå¤è¡¨èåæ¥è¯¢æ¶ï¼Oracleæä¾å¦ä¸joinç®æ³ï¼
nested loops
sort-merge
cluster -- ä¸é¨ç¨äºå¨ä¸ä¸ªclusterä¸çcluster tableãSQL Serverå 为没ætable clusterï¼å æ¤ä¹æ²¡æcluster joinã
hash join (not available with rule-based optimization)
SQL Serveråæä¾nested loopsï¼sort-mergeåhash join ã
åºå
Oracleä¸çsequenceæ¯ç¨æ·å®ä¹çï¼å¯å¤è¡¨å
±ç¨çæ°æ®ç»æãå®ç¨äºå¨è¡¨ä¸äº§çèªå¢å段ï¼é常ç¨æ¥äº§çprimary keyã
SQL Serveråå¨å个表ä¸è®¾ç½®èªå¢å段ï¼å æ¤å¹¶éæ¯ç¬ç«çæ°æ®ç»æï¼ä¹ä¸è½å¤è¡¨å
±ç¨ãå
¶åè½ä¸Oracle类似ã
ååºè¡¨ï¼ååºè§å¾åååºç´¢å¼
OracleåSQL Serverä¸é½å¯å°è¡¨ååºï¼å
¶åè½ç¸åã
æ§è¡è®¡å
æ§è¡è®¡åæThe EXPLAIN PLAN statement displays execution plans chosen by the Oracle optimizerã
OracleåSQL Serverä¸æ§è¡è®¡åçåè½ååçæ¯ç¸åçã
å¨Oracleä¸ä½¿ç¨SET AUTOTRACE ONæ¥æ§è¡SQL并æ¾ç¤ºæ§è¡è®¡åï¼è¥ä¸æ³è¿è¡SQLï¼åªæ¥çæ§è¡è®¡åå使ç¨SET AUTOTRACE TRACEONLYã
SQL Serverä¸çexecution planä»
æ¥çæ§è¡è®¡åï¼å¹¶ä¸è¿è¡SQLï¼å¦è¦æ¥çå®é
çè¿è¡æ
åµåç»è®¡æ°æ®ï¼åæ¯æ¥çactual planã
TlogåRedo log
å¨Oracleä¸ï¼ä½¿ç¨redo logæ¥å¤çäºå¡åæ»çæä½ï¼å¨SQL Serverä¸åæ¯Tlogãäºè
åè½ç¸è¿ã
Oracleä¸å½redo logå°log group填满åï¼é»è®¤ä¼èªå¨å½æ¡£ï¼ä½ä¹å¯ä»¥å
³é该åè½ã称为NOARCHIVELOG and ARCHIVELOG Modeã
http://docs.oracle.com/cd/B28359_01/server.111/b28310/archredo002.htmèå¨SQL Serverä¸å称为recovery modeãRecovery modeæä¸ç§ï¼full modeï¼simple modeåbulk logged modeãfull mode对åºARCHIVELOG modeï¼simple mode对åºNOARCHIVELOG modeãç产æ°æ®åºé½åºå·¥ä½å¨full modeæarchivelogä¸ã
é群
SQL Serveræä¾ä¸¤ç§å½¢å¼çclusterï¼Failover ClusteråAvalibility Groups
æ大çåºå«æ¯ï¼Failover Clusteræ两个å®ä¾å
±äº«ä¸ä¸ªç©çåå¨(é常æ¯SAN)ï¼ä¸åä¸æ¶å»åªæä¸ä¸ªå®ä¾è½è®¿é®ç©çåå¨ãå½å½åå®ä¾ç±äºåç§åå ï¼ä¾å¦å
åå ç¨è¶
è¿éå¼äºï¼å°±ä¼èªå¨åfailoverï¼å°å¦å¤ä¸ä¸ªå®ä¾ä¸ãä½æ»å¾æ¥è¯´ç©çåå¨åªæä¸ä»½ï¼è½ç¶SANçå®å
¨æ§å¾é«ãèAvalibility Groupså使ç¨äºæ´å¤æçæ¶æï¼ä½¿å¾ä¸åå
±äº«ä¸ä¸ªåå¨ï¼èçæ£å®ç°äºå¤å¯æ¬çé群ã
Oracleæä¾RAC--Real Application Clusterãç±äºå®åFailover Clusterä¸æ ·å
±äº«ä¸ä¸ªç©çåå¨ï¼å æ¤æ´æ¥è¿äºFailover Clusterãä½åºå«æ¯RACå®ç°äºå¤å®ä¾å¯åæ¶è®¿é®ä¸ä¸ªç©çåå¨ï¼å æ¤å®ç°äºå¨æè´è½½åè¡¡ï¼ä¹å¢å¤§äºç¼åçæ°æ®ï¼ä»èæé«äºæ¥è¯¢æçã缺ç¹æ¯å¯¹äºåæä½ï¼ç£çIOå¯è½ä¼æ为ç¶é¢ã
https://msdn.microsoft.com/en-us/library/ff929171.aspx#SQLServerFCå¤ç»´æ°æ®åº
Oracleæä¾ä¸¤ä¸ªå¤ç»´æ°æ®åºäº§åï¼Essbase å Oracle OLAP
SQL Serveræä¾SSAS