<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Seeking a humble career, facing a voodoo profession</title>
	<atom:link href="http://cfasky.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cfasky.wordpress.com</link>
	<description>A blog on finance and software development. There is no place for my true emotion</description>
	<lastBuildDate>Sun, 06 Nov 2011 12:46:46 +0000</lastBuildDate>
	<language>vi</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='cfasky.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Seeking a humble career, facing a voodoo profession</title>
		<link>http://cfasky.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://cfasky.wordpress.com/osd.xml" title="Seeking a humble career, facing a voodoo profession" />
	<atom:link rel='hub' href='http://cfasky.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Asterisk classpath hay  wildcard classpath trong Java 6.0</title>
		<link>http://cfasky.wordpress.com/2007/12/31/asterisk-classpath-hay-wildcard-classpath-trong-java-60/</link>
		<comments>http://cfasky.wordpress.com/2007/12/31/asterisk-classpath-hay-wildcard-classpath-trong-java-60/#comments</comments>
		<pubDate>Mon, 31 Dec 2007 15:43:02 +0000</pubDate>
		<dc:creator>pcdinh</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[classpath]]></category>
		<category><![CDATA[wildcard]]></category>

		<guid isPermaLink="false">http://cfasky.wordpress.com/2007/12/31/asterisk-classpath-hay-wildcard-classpath-trong-java-60/</guid>
		<description><![CDATA[Java 6.0 hỗ trợ * để xác định tất cả các file .jar nằm trong một thư mục, chỉ file .jar mà thôi. Nghĩa là thay vì gõ java -classpath .;C:\server\activemq5\lib\activemq-core-5.0.0.jar;C:\server\activemq5\lib\geronimo-jms_1.1_spec-1.0.jar;C:\server\activemq5\lib\commons-logging-1.1.jar Quote thì nay chỉ việc gõ java -classpath .;C:\server\activemq5\lib\* Quote Nếu classpath chỉ có 1 thành phần thì phải double quote nó lại để [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=22&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Java 6.0 hỗ trợ * để xác định tất cả các file .jar nằm trong một thư mục, chỉ file .jar mà thôi. Nghĩa là thay vì gõ</p>
<pre>java -classpath .;C:\server\activemq5\lib\activemq-core-5.0.0.jar;C:\server\activemq5\lib\geronimo-jms_1.1_spec-1.0.jar;C:\server\activemq5\lib\commons-logging-1.1.jar Quote</pre>
<p>thì nay chỉ việc gõ</p>
<pre>java -classpath .;C:\server\activemq5\lib\* Quote</pre>
<p>Nếu classpath chỉ có 1 thành phần thì phải double quote nó lại để hệ điều hành không hiểu lầm</p>
<pre>javac -cp "C:\Sun\AppServer\lib\*" HelloWorld.java</pre>
<p>Nếu có 2 thành  phần trở lên thì không cần</p>
<pre>javac -cp C:\Sun\AppServer\lib\*;D:\abc\ HelloWorld.java</pre>
<p>Nếu thư mục đó chỉ có 1 file jar thì không cần quote</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cfasky.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cfasky.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cfasky.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cfasky.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cfasky.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cfasky.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cfasky.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cfasky.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cfasky.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cfasky.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cfasky.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cfasky.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cfasky.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cfasky.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cfasky.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cfasky.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=22&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cfasky.wordpress.com/2007/12/31/asterisk-classpath-hay-wildcard-classpath-trong-java-60/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f94dd6b0315e44ce2cef6c31381319c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cfasky</media:title>
		</media:content>
	</item>
		<item>
		<title>Hỗ trợ chuẩn web trên các trình duyệt</title>
		<link>http://cfasky.wordpress.com/2007/12/28/h%e1%bb%97-tr%e1%bb%a3-chu%e1%ba%a9n-web-tren-cac-trinh-duy%e1%bb%87t/</link>
		<comments>http://cfasky.wordpress.com/2007/12/28/h%e1%bb%97-tr%e1%bb%a3-chu%e1%ba%a9n-web-tren-cac-trinh-duy%e1%bb%87t/#comments</comments>
		<pubDate>Fri, 28 Dec 2007 02:51:22 +0000</pubDate>
		<dc:creator>pcdinh</dc:creator>
				<category><![CDATA[browser]]></category>
		<category><![CDATA[css xhtml]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[standard]]></category>

		<guid isPermaLink="false">http://cfasky.wordpress.com/2007/12/28/h%e1%bb%97-tr%e1%bb%a3-chu%e1%ba%a9n-web-tren-cac-trinh-duy%e1%bb%87t/</guid>
		<description><![CDATA[http://www.webdevout.net/browser-support<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=21&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>http://www.webdevout.net/browser-support</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cfasky.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cfasky.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cfasky.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cfasky.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cfasky.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cfasky.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cfasky.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cfasky.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cfasky.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cfasky.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cfasky.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cfasky.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cfasky.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cfasky.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cfasky.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cfasky.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=21&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cfasky.wordpress.com/2007/12/28/h%e1%bb%97-tr%e1%bb%a3-chu%e1%ba%a9n-web-tren-cac-trinh-duy%e1%bb%87t/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f94dd6b0315e44ce2cef6c31381319c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cfasky</media:title>
		</media:content>
	</item>
		<item>
		<title>Các câu lệnh hệ thống dùng hằng ngày</title>
		<link>http://cfasky.wordpress.com/2007/12/24/cac-cau-lenh-he-thong-linux-dung-hang-ngay/</link>
		<comments>http://cfasky.wordpress.com/2007/12/24/cac-cau-lenh-he-thong-linux-dung-hang-ngay/#comments</comments>
		<pubDate>Mon, 24 Dec 2007 02:28:23 +0000</pubDate>
		<dc:creator>pcdinh</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://cfasky.wordpress.com/2007/12/24/cac-cau-l%e1%bb%87nh-h%e1%bb%87-th%e1%bb%91ng-dung-h%e1%ba%b1ng-ngay/</guid>
		<description><![CDATA[Kiểm tra ai đang login vào hệ thống và họ đang làm gì (tiến trình họ đang chạy) w hoặc w -s để xem danh sách ngắn hơn Kiểm tra ai đang trong hệ thống mà không quan tâm đến tiến trình who hay who -q để đếm tổng số người hay who -q để [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=20&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Kiểm tra ai đang login vào hệ thống và họ đang làm gì (tiến trình họ đang chạy)</p>
<pre><b>w</b></pre>
<p>hoặc</p>
<pre><b>w -s</b></pre>
<p>để xem danh sách ngắn hơn<br />
Kiểm tra ai đang trong hệ thống mà không quan tâm đến tiến trình</p>
<pre><b>who</b></pre>
<p>hay</p>
<pre><b>who -q</b></pre>
<p>để đếm tổng số người hay</p>
<pre><b>who -q</b></pre>
<p>để xem lần cuối họ boot máy tính là khi nào<br />
Kiểm tra tiến trình</p>
<pre><b>ps -ax | more</b> hay <b>ps -aux</b> hay <b>ps -eaf</b> hay <b>top</b></pre>
<p>Xem các phân vùng của ổ đĩa</p>
<pre><b>fdisk -l</b></pre>
<p>Kiểm tra dung lượng đĩa</p>
<pre><b>df -k</b></pre>
<p>hay</p>
<pre><b>df -h</b></pre>
<p>Kiểm tra thời gian chạy</p>
<pre><b>uptime</b></pre>
<p>Kiểm tra tình hình đăng nhập</p>
<pre><b>last -20</b></pre>
<p>Kiểm tra bộ nhớ</p>
<pre><b>free -m</b></pre>
<p>Kiểm tra tính kết nối của máy chủ với các máy tính khác qua card Ethernet và địa chỉ IP của chúng</p>
<pre><b>arp</b></pre>
<p>Kiểm tra các kết nối đến máy tính hiện thời (active Internet connections &#8230;)</p>
<pre><b>netstat |head</b></pre>
<p>Kiểm tra bảng routing</p>
<pre><b>route -v</b></pre>
<p>hoặc</p>
<pre><b>netstat -r</b></pre>
<p>Kiểm tra nhanh dung lượng các file của thư mục hiện tại hoặc 1 thư mục cụ thể (recursively): không dùng cho thư mục / (biết hậu quả rồi đấy)</p>
<pre><b>du -a</b></pre>
<p>sẽ in tất cả các file và dung lượng của chúng</p>
<pre><b>du -s /home/me</b></pre>
<p>sẽ in tổng số bytes của thư mục đó<br />
còn có thể chỉ định được độ sâu của thư mục để giới hạn số file cần tìm kiếm và đo trong thư mục đó</p>
<pre><b>du --max-depth=2 /home/me | sort -n</b></pre>
<p>Tìm kiếm file hay thư mục</p>
<pre><b>find / -name app_name_here -type d -xdev</b></pre>
<p>hay tìm kiếm các file có đuôi cụ thể</p>
<pre><b>find /home/me -name '*.out'</b></pre>
<p>hay tìm kiếm cả theo đuôi file và 1 phần nội dung của file</p>
<pre><b>find . -name '*.html' -exec grep 'mailto:foo@yahoo.com' {} \;</b></pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cfasky.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cfasky.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cfasky.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cfasky.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cfasky.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cfasky.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cfasky.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cfasky.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cfasky.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cfasky.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cfasky.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cfasky.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cfasky.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cfasky.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cfasky.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cfasky.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=20&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cfasky.wordpress.com/2007/12/24/cac-cau-lenh-he-thong-linux-dung-hang-ngay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f94dd6b0315e44ce2cef6c31381319c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cfasky</media:title>
		</media:content>
	</item>
		<item>
		<title>Use DOM to transform HTML table to PHP&#8217;s array</title>
		<link>http://cfasky.wordpress.com/2007/12/20/use-dom-to-transform-html-table-to-phps-array/</link>
		<comments>http://cfasky.wordpress.com/2007/12/20/use-dom-to-transform-html-table-to-phps-array/#comments</comments>
		<pubDate>Thu, 20 Dec 2007 07:35:27 +0000</pubDate>
		<dc:creator>pcdinh</dc:creator>
				<category><![CDATA[crawling]]></category>
		<category><![CDATA[data-processing]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[extracting]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[mining]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[scraping]]></category>

		<guid isPermaLink="false">http://cfasky.wordpress.com/2007/12/20/use-dom-to-transform-html-table-to-phps-array/</guid>
		<description><![CDATA[PHP5&#8242;s DomDocument $tableArray = array(); $dom = new DomDocument(); $dom-&#62;preserveWhiteSpace = false; $dom-&#62;loadHTML($xmlstr); // return DOMNodeList $rows = $dom-&#62;getElementsByTagName('tr'); // loop through each row // to work with DOMNode (nodeName, nodeType, parentNode, nodeValue, getAttribute for ($rowIndex = 0, $length = $rows-&#62;length; $rowIndex &#60; $length; $rowIndex++) { // DOMElement $currentRow = $rows-&#62;item($rowIndex); // the same to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=19&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>PHP5&#8242;s DomDocument</p>
<pre>
$tableArray = array();
$dom  = new DomDocument();
$dom-&gt;preserveWhiteSpace = false;
$dom-&gt;loadHTML($xmlstr);
// return DOMNodeList
$rows = $dom-&gt;getElementsByTagName('tr');

// loop through each row
// to work with DOMNode (nodeName, nodeType, parentNode, nodeValue, getAttribute
for ($rowIndex  = 0, $length = $rows-&gt;length; $rowIndex &lt; $length; $rowIndex++) {

    // DOMElement
   $currentRow = $rows-&gt;item($rowIndex);
   // the same to while($currentRow-&gt;hasChildNodes())
   // or foreach ($rows-&gt;item($rowIndex)-&gt;childNodes as $child) {

   if (null   !== $currentRow &amp;&amp; $currentRow-&gt;hasChildNodes()) {
       $cells  = $currentRow-&gt;childNodes;
       for ($cellIndex = 0, $length = $cells-&gt;length; $cellIndex &lt; $length; $cellIndex++) {
           $tableArray[$rowIndex][$cellIndex] = $cells-&gt;item($cellIndex)-&gt;nodeValue;
       }
   }
}</pre>
<p>Đây là một cách dùng DOM để loop qua một table đơn giản</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cfasky.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cfasky.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cfasky.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cfasky.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cfasky.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cfasky.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cfasky.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cfasky.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cfasky.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cfasky.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cfasky.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cfasky.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cfasky.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cfasky.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cfasky.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cfasky.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=19&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cfasky.wordpress.com/2007/12/20/use-dom-to-transform-html-table-to-phps-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f94dd6b0315e44ce2cef6c31381319c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cfasky</media:title>
		</media:content>
	</item>
		<item>
		<title>Chọn các bản ghi từ 2 tháng trở lại đây</title>
		<link>http://cfasky.wordpress.com/2007/12/17/ch%e1%bb%8dn-cac-b%e1%ba%a3n-ghi-t%e1%bb%ab-2-thang-tr%e1%bb%9f-l%e1%ba%a1i-day/</link>
		<comments>http://cfasky.wordpress.com/2007/12/17/ch%e1%bb%8dn-cac-b%e1%ba%a3n-ghi-t%e1%bb%ab-2-thang-tr%e1%bb%9f-l%e1%ba%a1i-day/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 07:17:14 +0000</pubDate>
		<dc:creator>pcdinh</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://cfasky.wordpress.com/2007/12/17/ch%e1%bb%8dn-cac-b%e1%ba%a3n-ghi-t%e1%bb%ab-2-thang-tr%e1%bb%9f-l%e1%ba%a1i-day/</guid>
		<description><![CDATA[Oracle: Mailing có một vấn đề: các record cũ quá 2 tháng thì không nên dùng lại theo đề nghị của nhóm. SELECT created_dtime FROM requests WHERE status = 0 AND created_dtime &#62; LAST_DAY(ADD_MONTHS(SYSDATE, -2)) Trước hết là xóa các record trong tháng cách đây 2 tháng: DELETE FROM requests WHERE status = 0 AND [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=18&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Oracle:</p>
<p>Mailing có một vấn đề: các record cũ quá 2 tháng thì không nên dùng lại theo đề nghị của nhóm.</p>
<pre>
SELECT created_dtime FROM requests
WHERE status = 0 AND created_dtime &gt; LAST_DAY(ADD_MONTHS(SYSDATE, -2))</pre>
<p>Trước hết là xóa các record trong tháng cách đây 2 tháng:</p>
<pre>
DELETE FROM requests
WHERE status = 0
AND created_dtime &lt; LAST_DAY(ADD_MONTHS(SYSDATE, -2))</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cfasky.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cfasky.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cfasky.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cfasky.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cfasky.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cfasky.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cfasky.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cfasky.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cfasky.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cfasky.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cfasky.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cfasky.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cfasky.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cfasky.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cfasky.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cfasky.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=18&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cfasky.wordpress.com/2007/12/17/ch%e1%bb%8dn-cac-b%e1%ba%a3n-ghi-t%e1%bb%ab-2-thang-tr%e1%bb%9f-l%e1%ba%a1i-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f94dd6b0315e44ce2cef6c31381319c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cfasky</media:title>
		</media:content>
	</item>
		<item>
		<title>Backup MySQL</title>
		<link>http://cfasky.wordpress.com/2007/11/15/backup-mysql/</link>
		<comments>http://cfasky.wordpress.com/2007/11/15/backup-mysql/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 18:50:34 +0000</pubDate>
		<dc:creator>pcdinh</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://cfasky.wordpress.com/2007/11/15/backup-mysql/</guid>
		<description><![CDATA[Step 1: mysqldump --single-transaction -uroot -p --all-databases --master-data=1 &#62; all_databases.sql Step 2: mysql -uroot &#60; all_databases.sql<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=17&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Step 1:</p>
<p><code>mysqldump --single-transaction -uroot -p --all-databases --master-data=1 &gt; all_databases.sql</code></p>
<p>Step 2:</p>
<p><code>mysql -uroot &lt; all_databases.sql</code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cfasky.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cfasky.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cfasky.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cfasky.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cfasky.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cfasky.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cfasky.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cfasky.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cfasky.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cfasky.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cfasky.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cfasky.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cfasky.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cfasky.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cfasky.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cfasky.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=17&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cfasky.wordpress.com/2007/11/15/backup-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f94dd6b0315e44ce2cef6c31381319c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cfasky</media:title>
		</media:content>
	</item>
		<item>
		<title>Database server farm and synchronization</title>
		<link>http://cfasky.wordpress.com/2007/11/12/database-server-farm-and-synchronization/</link>
		<comments>http://cfasky.wordpress.com/2007/11/12/database-server-farm-and-synchronization/#comments</comments>
		<pubDate>Mon, 12 Nov 2007 19:43:35 +0000</pubDate>
		<dc:creator>pcdinh</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://cfasky.wordpress.com/2007/11/12/database-server-farm-and-synchronization/</guid>
		<description><![CDATA[Tìm được công cụ này làm việc đồng bộ hóa dữ liệu trên nhiều server. Sau này sẽ cần đến các máy chủ read và một máy chủ master (write/read): http://symmetricds.org/ Việc đồng bộ hóa giữa master và master thì có công cụ này: http://blog.kovyrin.net/2007/04/23/master-master-replication-example-using-mmm/ http://datacharmer.org/<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=16&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Tìm được công cụ này làm việc đồng bộ hóa dữ liệu trên nhiều server. Sau này sẽ cần đến các máy chủ read và một máy chủ master (write/read): http://symmetricds.org/</p>
<p>Việc đồng bộ hóa giữa master và master thì có công cụ này: http://blog.kovyrin.net/2007/04/23/master-master-replication-example-using-mmm/</p>
<p>http://datacharmer.org/</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cfasky.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cfasky.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cfasky.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cfasky.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cfasky.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cfasky.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cfasky.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cfasky.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cfasky.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cfasky.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cfasky.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cfasky.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cfasky.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cfasky.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cfasky.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cfasky.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=16&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cfasky.wordpress.com/2007/11/12/database-server-farm-and-synchronization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f94dd6b0315e44ce2cef6c31381319c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cfasky</media:title>
		</media:content>
	</item>
		<item>
		<title>MySQL and JSON</title>
		<link>http://cfasky.wordpress.com/2007/11/12/mysql-and-json/</link>
		<comments>http://cfasky.wordpress.com/2007/11/12/mysql-and-json/#comments</comments>
		<pubDate>Mon, 12 Nov 2007 19:37:37 +0000</pubDate>
		<dc:creator>pcdinh</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://cfasky.wordpress.com/2007/11/12/mysql-and-json/</guid>
		<description><![CDATA[SELECT CONCAT("[", GROUP_CONCAT( CONCAT("{username:'",username,"'"), CONCAT(",email:'",email),"'}") ) ,"]") AS json FROM users; To [ {username:'mike',email:'mike@mikesplace.com'}, {username:'jane',email:'jane@bigcompany.com'}, {username:'stan',email:'stan@stanford.com'} ] Thanks to http://www.thomasfrank.se/mysql_to_json.html<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=15&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><code>SELECT<br />
CONCAT("[",<br />
GROUP_CONCAT(<br />
CONCAT("{username:'",username,"'"),<br />
CONCAT(",email:'",email),"'}")<br />
)<br />
,"]")<br />
AS json FROM users;</code></p>
<p>To</p>
<p><code>[<br />
{username:'mike',email:'mike@mikesplace.com'},<br />
{username:'jane',email:'jane@bigcompany.com'},<br />
{username:'stan',email:'stan@stanford.com'}<br />
]</code></p>
<p>Thanks to http://www.thomasfrank.se/mysql_to_json.html</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cfasky.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cfasky.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cfasky.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cfasky.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cfasky.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cfasky.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cfasky.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cfasky.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cfasky.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cfasky.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cfasky.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cfasky.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cfasky.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cfasky.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cfasky.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cfasky.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=15&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cfasky.wordpress.com/2007/11/12/mysql-and-json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f94dd6b0315e44ce2cef6c31381319c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cfasky</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle: Đếm số hàng trên từng cột</title>
		<link>http://cfasky.wordpress.com/2007/10/11/oracle-d%e1%ba%bfm-s%e1%bb%91-hang-tren-t%e1%bb%abng-c%e1%bb%99t/</link>
		<comments>http://cfasky.wordpress.com/2007/10/11/oracle-d%e1%ba%bfm-s%e1%bb%91-hang-tren-t%e1%bb%abng-c%e1%bb%99t/#comments</comments>
		<pubDate>Thu, 11 Oct 2007 02:43:47 +0000</pubDate>
		<dc:creator>pcdinh</dc:creator>
				<category><![CDATA[oracle]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://cfasky.wordpress.com/2007/10/11/oracle-d%e1%ba%bfm-s%e1%bb%91-hang-tren-t%e1%bb%abng-c%e1%bb%99t/</guid>
		<description><![CDATA[Tracking tình hình hợp đồng là một phần trong hệ RBAC. Nhiệm vụ là tổng hợp được số hàng theo từng cột theo từng tiêu chí. Có một bảng theo dõi contract của các user và một bảng theo dõi từng số lần access vào các tài nguyên hợp đồng. Cách 1: Thuần túy ASCII [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=14&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Tracking tình hình hợp đồng là một phần trong hệ RBAC. Nhiệm vụ là tổng hợp được số hàng theo từng cột theo từng tiêu chí. Có một bảng theo dõi contract của các user và một bảng theo dõi từng số lần access vào các tài nguyên hợp đồng.</p>
<p>Cách 1: Thuần túy ASCII</p>
<pre>
$sql = "SELECT c.contract_id FROM

(SELECT

c.contract_id, c.contract_end_date, c.contract_priority,

ct.max_company_count, ct.max_report_count

FROM contracts c, contract_types ct

WHERE c.contract_type_id = ct.contract_type_id

AND c.contract_id IN ($validContracts)

AND c.user_id    = :user_id) c,

(SELECT

c.contract_id,

COUNT(DISTINCT tr.company_id) company_count

FROM contracts c, contract_trackers tr

WHERE c.contract_id = tr.contract_id

AND c.contract_id IN ($validContracts)

GROUP BY c.contract_id) cc1,

(SELECT

c.contract_id,

COUNT(DISTINCT tr.number) company_count

FROM contracts c, contract_trackers tr

WHERE c.contract_id = tr.contract_id

AND c.contract_id IN ($validContracts)

GROUP BY c.contract_id) cc2,

(SELECT

c.contract_id,

COUNT(DISTINCT tr.report_file) report_count

FROM contracts c, contract_trackers tr

WHERE c.contract_id = tr.contract_id

AND c.contract_id IN ($validContracts)

GROUP BY c.contract_id) cc3

WHERE c.contract_id     = cc1.contract_id

AND cc1.contract_id     = cc2.contract_id

AND cc2.contract_id     = c.contract_id

AND (c.max_company_count IS NOT NULL AND

c.max_company_count &gt; (CASE

WHEN cc1.company_count &gt; cc2.company_count THEN cc1.company_count

ELSE cc2.company_count

END))

AND (c.max_report_count IS NOT NULL AND

c.max_report_count &gt; cc3.report_count)

ORDER BY c.contract_priority DESC";</pre>
<p>Cách 2: Lợi dụng đặc điểm của COUNT DISTINCT của Oracle</p>
<pre>
SELECT c.contract_id

FROM contracts c,

contract_types ct,

(SELECT

c1.contract_id,

COUNT(DISTINCT tr.company_id) company_count,

COUNT(DISTINCT tr.number) company_count2,

COUNT(DISTINCT tr.report_file) report_count

FROM contracts c1,

contract_trackers tr

WHERE c1.contract_id = tr.contract_id

AND c1.contract_id IN (4)

GROUP BY c1.contract_id) tr

WHERE c.contract_type_id = ct.contract_type_id

AND tr.contract_id = c.contract_id

AND c.contract_id IN (4)

AND c.user_id    = 8

AND (ct.max_company_count IS NOT NULL AND

ct.max_company_count &gt; (CASE

WHEN tr.company_count &gt; tr.company_count2 THEN tr.company_count

ELSE tr.company_count2

END))

AND (ct.max_report_count IS NOT NULL AND

ct.max_report_count &gt; tr.report_count)

ORDER BY c.contract_priority DESC</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cfasky.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cfasky.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cfasky.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cfasky.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cfasky.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cfasky.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cfasky.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cfasky.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cfasky.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cfasky.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cfasky.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cfasky.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cfasky.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cfasky.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cfasky.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cfasky.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=14&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cfasky.wordpress.com/2007/10/11/oracle-d%e1%ba%bfm-s%e1%bb%91-hang-tren-t%e1%bb%abng-c%e1%bb%99t/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f94dd6b0315e44ce2cef6c31381319c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cfasky</media:title>
		</media:content>
	</item>
		<item>
		<title>How to decrease length of fixed width column in Oracle</title>
		<link>http://cfasky.wordpress.com/2007/09/24/how-to-decrease-length-of-fixed-width-column-in-oracle/</link>
		<comments>http://cfasky.wordpress.com/2007/09/24/how-to-decrease-length-of-fixed-width-column-in-oracle/#comments</comments>
		<pubDate>Mon, 24 Sep 2007 11:37:07 +0000</pubDate>
		<dc:creator>pcdinh</dc:creator>
				<category><![CDATA[oracle]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://cfasky.wordpress.com/2007/09/24/how-to-decrease-length-of-fixed-width-column-in-oracle/</guid>
		<description><![CDATA[Lọ mọ cả ngày tìm ra lý do tại sao module reset password lại không hoạt động. Hóa ra cột chứa password có kiểu CHAR(42) trong khi password chỉ dài có 40 kí tự. Công việc giảm độ dài của field này cũng lắm nhiêu khê vì không thể làm đơn giản kiểu ALTER TABLE [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=13&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Lọ mọ cả ngày tìm ra lý do tại sao module reset password lại không hoạt động. Hóa ra cột chứa password có kiểu CHAR(42) trong khi password chỉ dài có 40 kí tự. Công việc giảm độ dài của field này cũng lắm nhiêu khê vì không thể làm đơn giản kiểu</p>
<p><code>ALTER TABLE users MODIFY password CHAR(40);</code></p>
<p>vì sẽ có lỗi 01441 ngay lập tức khi mà bảng đã có dữ liệu.</p>
<p>Vậy phải làm thế nào:</p>
<p>+ Thêm cột mới vào ngay sau cột cũ</p>
<p>+ Trao đổi dữ liệu 2 cột</p>
<p>+ Drop cột cũ</p>
<p>Tuy nhiên MySQL is more advanced than Oracle  trong cái vụ ADD BEFORE/AFTER này nhiều. Oracle thì phải làm như sau:</p>
<p><code>/** Add a new column with desired width */<br />
ALTER TABLE users ADD (password2 char(40));<br />
/** Trimming trailing whitespace and swap */<br />
UPDATE users SET password2 = TRIM(TRAILING ' ' FROM 'password');</code></p>
<p><code>COMMIT;<br />
/** Drop old column */<br />
ALTER TABLE users DROP COLUMN user_password;<br />
/** Change to old name */<br />
ALTER TABLE users RENAME COLUMN password2 TO password;<br />
/** Prepare for the temporary table */<br />
ALTER TABLE users RENAME TO users2;</code></p>
<p><code>/** Reserve the order of the field so not insert/update query will be affected */<br />
CREATE TABLE users NOLOGGING /* unrecoverable */<br />
AS<br />
SELECT user_id, username, password,<br />
email, lastname, firstname, company, reg_dtime,<br />
user_act_code, status, news_subscriber, duration_type_id,<br />
salutation_id, referrer_id, another_referrer, language_id, gender_id<br />
FROM users2;</code><br />
<code>/** GC */<br />
DROP TABLE users2;</code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cfasky.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cfasky.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cfasky.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cfasky.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cfasky.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cfasky.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cfasky.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cfasky.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cfasky.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cfasky.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cfasky.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cfasky.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cfasky.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cfasky.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cfasky.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cfasky.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cfasky.wordpress.com&amp;blog=1031322&amp;post=13&amp;subd=cfasky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cfasky.wordpress.com/2007/09/24/how-to-decrease-length-of-fixed-width-column-in-oracle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f94dd6b0315e44ce2cef6c31381319c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cfasky</media:title>
		</media:content>
	</item>
	</channel>
</rss>
