<?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/"
	>

<channel>
	<title>SQLite &#8211; 記下來</title>
	<atom:link href="https://noter.tw/tag/sqlite/feed/" rel="self" type="application/rss+xml" />
	<link>https://noter.tw</link>
	<description>一路上踩到的坑、遇到的問題，一點一滴記下來，希望能幫助到需要的人~</description>
	<lastBuildDate>Wed, 06 Nov 2019 07:12:30 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.3</generator>

<image>
	<url>https://noter.tw/wp-content/uploads/cropped-old-1130742_1920-1-32x32.jpg</url>
	<title>SQLite &#8211; 記下來</title>
	<link>https://noter.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>SQLite 圖形化操作軟體 &#8211; SQLite Expert Personal (2)</title>
		<link>https://noter.tw/1558/sqlite-%e5%9c%96%e5%bd%a2%e5%8c%96%e6%93%8d%e4%bd%9c%e8%bb%9f%e9%ab%94-sqlite-expert-personal-2/</link>
					<comments>https://noter.tw/1558/sqlite-%e5%9c%96%e5%bd%a2%e5%8c%96%e6%93%8d%e4%bd%9c%e8%bb%9f%e9%ab%94-sqlite-expert-personal-2/#respond</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Mon, 19 Dec 2011 14:12:54 +0000</pubDate>
				<category><![CDATA[資料庫]]></category>
		<category><![CDATA[postman]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[auto_increment]]></category>
		<category><![CDATA[gui]]></category>
		<category><![CDATA[index]]></category>
		<guid isPermaLink="false">http://wazai.co.cc/?p=1558</guid>

					<description><![CDATA[<p>小蛙在上一篇文章中介紹 SQLite Expert Personal 簡單的使用方式，這篇文章小蛙要說明怎麼設定每一筆資料都有一個可以自動新增的id，相當於Oracle的SEQUENCE，MySQL的&#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/1558/sqlite-%e5%9c%96%e5%bd%a2%e5%8c%96%e6%93%8d%e4%bd%9c%e8%bb%9f%e9%ab%94-sqlite-expert-personal-2/" data-wpel-link="internal">SQLite 圖形化操作軟體 &#8211; SQLite Expert Personal (2)</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>小蛙在上一篇文章中介紹 SQLite Expert Personal 簡單的使用方式，這篇文章小蛙要說明怎麼設定每一筆資料都有一個可以自動新增的id，相當於Oracle的SEQUENCE，MySQL的AUTO_INCREMENT，設定及運作方式跟MySQL的差不多，只是小蛙一開始要設定的時候還是小卡了一下。<br />
<span id="more-1558"></span><br />
這裡小蛙用實際的例子來說明，原本在設計這個資料表的時候，目的是在儲存台灣的郵遞區號，ex.台北市，大安區，Da&#8217;an Dist.,，這個資料表裡面小蛙也設定了id屬性，目的是讓比鄉鎮區以下的例如：村、里&#8230;等，可以用id來辨別是在哪個鄉鎮區。小蛙在設計到一半的時候，發現SQLite Expert Personal裡面預覽資料的時候有個欄位叫做RecNo，小蛙以為這套GUI會產生自動遞增的欄位方便使用者操作，但當小蛙透過程式存取SQLite的時候卻又得不到RecNo這個欄位的值才恍然大悟，原來這套軟體產生的RecNo只是方便使用者在GUI操作的時候辨識資料筆數。下圖是小蛙被騙的RecNo。<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-14.png" data-wpel-link="internal"><img fetchpriority="high" decoding="async" title="sqlite-14" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-14.png" alt="sqlite 14 SQLite 圖形化操作軟體 - SQLite Expert Personal (2)" width="423" height="251"></a><br />
在已經建立好資料，卻又要新增not null的auto_increment欄位的方法也不難，只是做個小動作騙騙這套管理工具。在Design下的Fields頁面中選擇下方的Add，將要新增的id欄位補上，注意Type一定要用INTEGER。<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-15.png" data-wpel-link="internal"><img decoding="async" class="alignnone size-large wp-image-1563" title="sqlite-15" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-15-580x419.png" alt="sqlite 15 SQLite 圖形化操作軟體 - SQLite Expert Personal (2)" width="580" height="419"></a><br />
如果上一步直接把Not null打勾的話一定會出現這個錯誤，因為已經把資料建好，而新增欄位如果是Not null，就違反了規則(新增出來的欄位裡面沒有值，當然就違反了)。<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-161.png" data-wpel-link="internal"><img decoding="async" class="alignnone size-large wp-image-1564" title="sqlite-16" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-161-580x419.png" alt="sqlite 161 SQLite 圖形化操作軟體 - SQLite Expert Personal (2)" width="580" height="419"></a><br />
只要把Not null的勾勾先取消，點選OK後，繼續切換到Indexes頁面，點選下方Add後，在要自動遞增的欄位上點兩下(會跑到右邊)，之後會發現上方有三個勾，視需求勾選(Primary: PK，主要可以識別的的 Key，Unique: 唯一值，不可以重複，Autoincrement: 每一筆紀錄都會自動增加1)。確定後，點選下方的Apply就不會在出現上面的錯誤囉！<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-18.png" data-wpel-link="internal"><img decoding="async" class="alignnone size-large wp-image-1559" title="sqlite-18" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-18-580x419.png" alt="sqlite 18 SQLite 圖形化操作軟體 - SQLite Expert Personal (2)" width="580" height="419"></a><br />
最後因為我們新增了Autoincrement這個屬性，因此原本新增的id欄位就不再是null，接著再回到Fields編輯剛剛的id欄位，把id欄位的Not null勾選就完成囉！<br />
最後可以把經常查詢或是需要查詢的欄位建立Index，如此一來可以加快我們搜尋資料的速度。以下這段內容節錄自<strong><a href="http://www.1keydata.com/tw/sql/sql-create-index.html" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">SQL語法教學<span class="wpel-icon wpel-image wpel-icon-6"></span></a></strong>。該網站舉了一個翻書的例子，如果我們在書裡有索引(可以看成是目錄)，就可以很快的找到我們要查找的資料；倘若有一本書沒有任何目錄，那麼就必須逐字去尋找。</p>
<blockquote><p>索引 (Index) 可以幫助我們從表格中快速地找到需要的資料。<br />
&#8230;<br />
從資料庫表格中尋找資料也是同樣的原理。如果一個表格沒有索引的話，資料庫系統就需要將整個表格的資料讀出 (這個過程叫做&#8217;table scan&#8217;)。若有適當的索引存在，資料庫系統就可以先由這個索引去找出需要的資料是在表格的什麼地方，然後直接去那些地方抓資料。這樣子速度就快多了。</p></blockquote>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/1558/sqlite-%e5%9c%96%e5%bd%a2%e5%8c%96%e6%93%8d%e4%bd%9c%e8%bb%9f%e9%ab%94-sqlite-expert-personal-2/" data-wpel-link="internal">SQLite 圖形化操作軟體 &#8211; SQLite Expert Personal (2)</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/1558/sqlite-%e5%9c%96%e5%bd%a2%e5%8c%96%e6%93%8d%e4%bd%9c%e8%bb%9f%e9%ab%94-sqlite-expert-personal-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SQLite 圖形化操作軟體 &#8211; SQLite Expert Personal (1)</title>
		<link>https://noter.tw/1554/sqlite-%e5%9c%96%e5%bd%a2%e5%8c%96%e6%93%8d%e4%bd%9c%e8%bb%9f%e9%ab%94-sqlite-expert-personal-1/</link>
					<comments>https://noter.tw/1554/sqlite-%e5%9c%96%e5%bd%a2%e5%8c%96%e6%93%8d%e4%bd%9c%e8%bb%9f%e9%ab%94-sqlite-expert-personal-1/#comments</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Fri, 16 Dec 2011 16:46:18 +0000</pubDate>
				<category><![CDATA[資料庫]]></category>
		<category><![CDATA[postman]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[sqlite explorer]]></category>
		<category><![CDATA[sqlite gui]]></category>
		<guid isPermaLink="false">http://wazai.co.cc/?p=1554</guid>

					<description><![CDATA[<p>小蛙今天要介紹一套圖形化的SQLite管理軟體，目前像Android, iOS … 等手持式裝置內部都支援使用SQLite，不外乎是因為它方便、小、速度快，SQLite不像一般MySQL、Oracle&#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/1554/sqlite-%e5%9c%96%e5%bd%a2%e5%8c%96%e6%93%8d%e4%bd%9c%e8%bb%9f%e9%ab%94-sqlite-expert-personal-1/" data-wpel-link="internal">SQLite 圖形化操作軟體 &#8211; SQLite Expert Personal (1)</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>小蛙今天要介紹一套圖形化的SQLite管理軟體，目前像Android, iOS … 等手持式裝置內部都支援使用SQLite，不外乎是因為它方便、小、速度快，SQLite不像一般MySQL、Oracle、MSSQL這麼複雜，我們可以把SQLite想像成一個檔案(實際上存好之後也只有一個檔案)，但這一個檔案又比Microsoft Access有更大的便利性(可以在很多平台使用，不會只鎖定微軟平台)，想更了解SQLite可以參考<a href="http://www.sqlite.org/datatype3.html" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">SQLite官方說明書<span class="wpel-icon wpel-image wpel-icon-6"></span></a>、或者是<a href="http://zh.wikipedia.org/wiki/SQLite" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">WIKI-SQLite<span class="wpel-icon wpel-image wpel-icon-6"></span></a>。<strong><a href="http://www.sqliteexpert.com/index.html" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">SQLite Expert Personal<span class="wpel-icon wpel-image wpel-icon-6"></span></a></strong>是小蛙今天要介紹的軟體，它不只可以瀏覽SQLite內儲存的資料，同時也可以進行新增、修改、刪除…等操作，就像官網首頁寫的「SQLite Expert: A powerful administration tool for your SQLite databases」。<br />
<span id="more-1554"></span><br />
注意：這篇文章主要是以圖形化工具操作SQLite，並不會讓你學到SQLite指令操作。<br />
先到官網下載SQLite Expert Personal免費版， 上面的是專業版，只能試用30天，那小蛙只是需要一些資料庫基本操作，選擇下面的License是Freeware的個人免費版。下載完之後安裝，預設一直下一步直到安裝完成。<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-16.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="sqlite-16" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-16_thumb.png" alt="sqlite-16" width="574" height="517" border="0"></a><br />
安裝完成後執行SQLite Expert Personal，在桌面可以看到圖示，如果沒有的話到開始所有程式(程式集)裡面去找「SQLite Expert」，點兩下執行。<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-11.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="sqlite-11" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-11_thumb.png" alt="sqlite-11" width="84" height="94" border="0"></a><br />
啟動之後我們必須先建立一個新的資料庫，點選左上角紅色框框新增資料庫，並且輸入相關設定。<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-1.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="sqlite-1" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-1_thumb.png" alt="sqlite-1" width="574" height="432" border="0"></a><br />
新增完資料庫後，畫面左邊可以看到小蛙剛剛新增的資料庫「postman」，在資料庫上點選滑鼠右鍵，選擇「New Table」來新增需要的表單。<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-2.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="sqlite-2" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-2_thumb.png" alt="sqlite-2" width="574" height="432" border="0"></a><br />
先輸入「Table name」，這邊小蛙輸入「post_code」，並且在下面「Fields」的部份新增需要的資料表欄位。這邊要注意的是如果要使用「自動遞增 auto_increment」功能的話，必須要把該欄位的「Type」設定成「INTEGER」。新增完成後點選下方的「Apply」。<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-3.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="sqlite-3" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-3_thumb.png" alt="sqlite-3" width="574" height="432" border="0"></a><br />
畫面的左邊可以看到新增完成的Table，右邊則是一些相關的操作畫面，像是「Database」、「SQL」、「Data」、「Design」、「DDL」。<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-5.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="sqlite-5" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-5_thumb.png" alt="sqlite-5" width="574" height="432" border="0"></a><br />
「SQL」頁面可以讓我們測試所寫的SQL正不正確。<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-6.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="sqlite-6" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-6_thumb.png" alt="sqlite-6" width="574" height="432" border="0"></a><br />
「Data」可以瀏覽目前資料表裡面包含的資料，並且新增、修改、刪除這些資料。小蛙試了一下才知道要怎麼新增，點選「+」符號後會出現如下圖多一列都是&lt;null&gt;的資料，在該列上點兩下就可以進入編輯畫面(別點選有Filter的那列)。<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-7.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="sqlite-7" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-7_thumb.png" alt="sqlite-7" width="574" height="432" border="0"></a><br />
「Design」就是剛剛我們新增資料表及欄位的地方，可以提供修改、刪除欄位，也包括了Index, FK, Constraints, Triggers 等等的建立。<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-8.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="sqlite-8" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-8_thumb.png" alt="sqlite-8" width="574" height="432" border="0"></a><br />
「DDL」則是可以看到這個資料表建立的語法。<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-9.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="sqlite-9" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-9_thumb.png" alt="sqlite-9" width="574" height="432" border="0"></a><br />
設定完所有欄位後就可以開始新增資料了，新增資料以及設定Index, 自動遞增…等，小蛙將在下一篇文章中說明。下圖是剛剛我們建立的sqlite，別看這小小的檔案，SQLite可是麻雀雖小，五臟俱全呢！<br />
<a href="https://noter.tw/wp-content/uploads/2011/12/sqlite-10.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="sqlite-10" src="https://noter.tw/wp-content/uploads/2011/12/sqlite-10_thumb.png" alt="sqlite-10" width="76" height="74" border="0"></a></p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/1554/sqlite-%e5%9c%96%e5%bd%a2%e5%8c%96%e6%93%8d%e4%bd%9c%e8%bb%9f%e9%ab%94-sqlite-expert-personal-1/" data-wpel-link="internal">SQLite 圖形化操作軟體 &#8211; SQLite Expert Personal (1)</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/1554/sqlite-%e5%9c%96%e5%bd%a2%e5%8c%96%e6%93%8d%e4%bd%9c%e8%bb%9f%e9%ab%94-sqlite-expert-personal-1/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
	</channel>
</rss>
