2008年6月13日 星期五

select * from goods_file
AS OF TIMESTAMP timestamp'2008-06-12 14:53:47'
where g_no = 11080531367948

2008年6月11日 星期三

Oracle DBCA (Database Configuration Assistant)

Template
1.Data Warehouse
2.Transaction Processing
3.General Purpose


1.Dedicated Server Mode
2.Shared Server Mode

Reset SYS , SYSTEM account default password.

Oracle Instance
1.System Global Area
SGA_MAX_SIZE , DB_CACHE_SIZE , LOG_BUFFER , SHARED_POOL_SIZE , LARGE_POOL_SIZE
2.Background processes

Data Cache Buffer
1.Write List (dirty buffers wait for write to disk)
2.LRU list (free , dirty , pinned buffers)
LRU Least Recently Used
MRU Most Recently Used

Total Size = DB_BLOCK_SIZE(2~32KB) * DB_BLOCK_BUFFERS

Redo Log Buffer (bytes)
Default : Redo Log Buffer = 4 * System Block Size

Share Pool (SHARED_POOL_SIZE = 8 MB in 32-bit , 6 MB in 64-bit system )
1. Library cache
Share SQL Area (SQL parse tree , execution plan)
Private SQL Area
PL/SQL Program Unit
2. Dictionary cache
parse information like table , view name , column name , data type
user privileges

DBWn - Database Writer
write dirty blocks from Data Cache Buffer to data files. => checkpoint
default only DBW0
btw in OLTP , update busy
DBW1~DBW9 is prefered.


LGWR - Log Writer
Write to redo log files
When
1. transaction commited
2. Auto Writing each 3 seconds.
3. free size of Redo log buffer is less than 1/3.
4. Before DBWn write dirty blocks to data files
Write - ahead protocol :
if LGWR write Redo data to redo logs finished
DBWn write dirty blocks to data files
else
Call LGWR write Redo data to redo logs
Then DBWn do its work.

SMON - System Monitor
Database Start Recovery checking
1. After Database restart , nessesary recovery activities.
2. Release not used temporary segments.
3. Collect and manage free extents
4. Recovery abort transaction.

PMON - Process Monitor
1. Recovery abort Process
2. Clear Data Buffer cache Unused block, reset transaction table status,
Unlock row , remove terminated process ID.

CKPT - Checkpoint
1. make sure MRU Dirty Data will write to data file regularly.
2. when instance recovery , can ignore the record before the currently checkpoint.
3. if(checkpoint finished)
CKPT call DBWn;
Then update control file and header of data file.
RECO (Recover)
handle transaction in Cluster database.
in-doubt transaction . transaction between servers.

ARCn (Archiver) (LOG_ARCHIVE_MAX_PROCESSES LIMIT IS 10 OR ALTER SYSTEM to change)
log switch. Archived logs.
indeed, Oracle will judge it automatically.

2008年6月9日 星期一

MySQL Index Building Tips

1. 資料種類較少 ex 男, 女 的index 在複合 index 中 放越前越好 (B-Tree divide)

2. 會按 index 建立的時間來吃, 吃到就不會繼續往下找,即使有更好的index~~

3. where date_format('A') = '20080723'
mod('A') = 5
=> 在設計之初 , 就要規劃好 避免在where 中 轉 格式.

4. where A is NULL => 會 full table scan
可以放default , ex: '0' => where A = 0 or "NULL" => where A = 'NULL'

2008年6月2日 星期一

Oracle Text

Form http://www.oracle.com/technology/products/text/index.html
Oracle Text
Oracle Text uses standard SQL to index, search, and analyze text and documents stored in the Oracle database, in files, and on the web. Oracle Text can perform linguistic analysis on documents, as well as search text using a variety of strategies including keyword searching, context queries, Boolean operations, pattern matching, mixed thematic queries, HTML/XML section searching, and so on. It can render search results in various formats including unformatted text, HTML with term highlighting, and original document format. Oracle Text supports multiple languages and uses advanced relevance-ranking technology to improve search quality. Oracle Text also offers advanced features like classification, clustering, and support for information visualization metaphors.

Oracle TimesTen In-Memory Database

http://www.oracle.com/timesten/index.html

Database Built in Memory : Oracle TimesTen

2008年5月27日 星期二

Select * From ap2_class_mapping Where class_id in ('0002','0012')
=> 會吃 index
Select * From ap2_class_mapping Where class_id in (0002,0012)
=> Full Scan

=> 有沒有單引號差很多

2008年5月17日 星期六

From ITHome
MySQL漸有大型企業採用,取得認證就業機會高
文/黃彥棻 (記者) 2008-02-01

MySQL在推出5.0版本時,將證照名稱正名,可以從證照看出是資料庫開發或者是資料庫管理員,目前臺灣若要考CMDEV和CMDBA,可以到全省VUE考試中心線上報名及考試。

由開放原始碼撰寫的資料庫產品MySQL,日前雖然被昇陽(Sun)併購,但因為MySQL有免費版和商業版,成為臺灣中小企業和個人用戶使用頻率最高的資料庫產品。但近年有不少大型企業開始評估或已經使用MySQL後,也使得取得MySQL證照的IT人,工作機會水漲船高。

MySQL資料庫因為是開放源碼撰寫的產品,對於許多SOHO或者是中小企業主而言,免費又兼具效能的MySQL,往往是第一也是唯一的資料庫選擇。巨匠電腦PHP與MySQL課程講師梁國亮表示,近來也發現有一些系統廠商或者是中小企業主,將MySQL作為單純進銷存系統或者是ERP(企業資源規畫)的後端資料庫使用。此外,也發現有一些中大型的網站或者是公家機關,也開始使用MySQL,「使用對象不再侷限以往的中小企業或者是SOHO族。」梁國亮說。

不只如此,梁國亮也觀察到,許多重量級廠商已經在部分的產品線上使用MySQL,例如電信業者彙整繳費資料到前端資料庫,就是使用MySQL;搜尋引擎業者某一些前端的資料庫,或者是某些大型的電子商務網站,甚至是美國最著名的網路書店Amazon,都有部分使用MySQL資料庫。

除了這些大型企業也開始使用MySQL資料庫外,梁國亮自身的教學經驗中也發現,有某家DRAM廠商,正在積極評估是否可以部分採用較為便宜的 MySQL資料庫,作為生產數據分析之用。他進一步表示,這家企業主對於MySQL的課程,要求到非常進階的使用功能,對於效能的調校與掌握,也要求務必徹底了解。梁國亮表示,這間DRAM業者為了降低成本,開始評估採用MySQL資料庫的可能性,如果效能上能夠符合該業者的需求,「光是1年資料庫軟體的授權費用,就可以節省上千萬元,」梁國亮說。

目前MySQL有3張相關證照,分別是基礎開發的CMDEV(Certified MySQL Developer)、資料庫管理員的CMDBA(Certified MySQL DBA)和高階叢集運算的CMCDBA(Certified MySQL Cluster DBA)。梁國亮目前已經取得CMDEV和CMDBA兩張證照,而CMCDBA則是去年下半年才推出的新證照。

梁國亮指出,目前證照的名稱是去年底MySQL升級到5.0版後,才重新命名的,原本在MySQL 4.0版本中,分成Core和Profession的兩張證照,難以從證照名稱上就看出原來Core就是資料庫開發工程師,Profession就是資料庫管理員。所以在MySQL 5.0版本中,才從善如流,從證照名稱就可以看出特色。

CMDEV和CMDBA都需要考2科上機的實機考試,單選題和複選題都有。梁國亮經驗表示,在考取CMDEV證照時,因為偏重開發的功能,「考生對於SQL的語法必須非常的了解,」梁國亮依自己考試經驗表示,考題上常出現考你一串語法後,問考生之後的執行結果為何,「這必須對於SQL語法非常熟悉。」他說。

至於CMDBA的考試上,梁國亮表示,主要是考驗考生對資料庫管理的概念和相關程序的了解,不論是使用者、權限管理,資料庫維護,包含備份、還原、目錄(Index)或重整等,都必須相當熟悉。他說,因為考試重視程序,考題就會有類似「資料庫壞了,正確的挽救程序應該如何執行?」的題目。

梁國亮表示,對於一個資料庫管理員而言,MySQL只是其中的一個產品類型,下一步發展的方向,不論是微軟的SQL Server 2005或者是大型的商用資料庫軟體如甲骨文或SAP等,都是進階學習的選擇。

目前臺灣若要考CMDEV和CMDBA,可以到全省VUE考試中心線上報名及考試。文⊙黃彥棻