<?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>網頁設計,網路行銷新知 &#187; BUSINESSWING &#8211; 整合提供網頁設計,網站企劃,網路行銷等新知</title>
	<atom:link href="http://businesswing.net/tag/web-2-0/feed/" rel="self" type="application/rss+xml" />
	<link>http://businesswing.net</link>
	<description>提供的不只是網頁設計,網頁製作,網頁企劃,更重視網頁優化(SEO)及網頁行銷概念的注入</description>
	<lastBuildDate>Wed, 06 Jul 2011 09:12:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>14-3 變更資料SQL語法</title>
		<link>http://businesswing.net/webdesign/php-sql_data_syntax/</link>
		<comments>http://businesswing.net/webdesign/php-sql_data_syntax/#comments</comments>
		<pubDate>Tue, 24 May 2011 06:17:49 +0000</pubDate>
		<dc:creator>bwingnet</dc:creator>
				<category><![CDATA[網頁程式PHP]]></category>
		<category><![CDATA[網頁設計]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://businesswing.net/?p=2068</guid>
		<description><![CDATA[前面所提到的是查詢資料表內資料的語法，其實SQL語法內也有一些語法是可變更資料的語法。變更資料的語法包涵了新增（insert into）、刪除（delete）與更新（update）。 14-3-1 備份資料 由於新增（insert into）、刪除（delete）與更新（update）均會變更資料表內容，為了避免影響原有資料，在此我們使用SQL語法備份原資料表為新資料表，備份指令為：「create table 新資料表 select * from 舊資料表」，這個章節內我們需要將多個資料表進行備份，所以請您於phpMyAdmin的SQL視窗內依序輸入以下語法後按下執行鈕執行： 【表3、備份原有資料表】 語法 create table insertemployees select * from employees; create table insertjob select * from job; create table updateemployees1 select * from employees; create table updateemployees2 select * from employees; create table updateemployees3 select * from employees; create table updatejob select * from [...]]]></description>
		<wfw:commentRss>http://businesswing.net/webdesign/php-sql_data_syntax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>14-2 討論與日期有關的查詢</title>
		<link>http://businesswing.net/webdesign/php-date_of_the_query/</link>
		<comments>http://businesswing.net/webdesign/php-date_of_the_query/#comments</comments>
		<pubDate>Mon, 23 May 2011 10:52:55 +0000</pubDate>
		<dc:creator>bwingnet</dc:creator>
				<category><![CDATA[網頁程式PHP]]></category>
		<category><![CDATA[網頁設計]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://businesswing.net/?p=2066</guid>
		<description><![CDATA[介紹完多個資料表之間的資料查詢後，接著說明與日期有關的函數，在此先整理如以下列表（在此僅列出日期部分）： 【表1、用於SQL語法的MySQL日期函數】 分類 函數名稱 作用 年份 year(date) 返回date的年份，範圍在1000到9999。 四季 quarter(date) 返回date屬於一年中第幾季，範圍1到4。 月份 month(date) 返回date的月份。 &#160; monthname(date) 返回date的月份名稱。 星期 dayofweek(date) 返回日期date的星期索引(1=星期天，2=星期一, ……7=星期六)。 &#160; dayname(date) 返回date的星期名稱。 日期 dayofmonth(date) 返回date的月份中日期，在1到31範圍內。 &#160; dayofyear(date) 返回date在一年中的日數, 在1到366範圍內。 日期間隔 datediff(date1,date2) 返回兩個日期之間天數。 &#160; date_add(date,interval expr type) 日期添加指定的時間間隔 14-2-1 年月日查詢 以下將針對上面的函數作資料查詢。當您想要查詢檢索emploees資料表內每一個人的「birthday」欄位內容，並且進行分析。首先，我們希望篩選出每一個人生日的年份、季、月份、月份名稱，請您於phpMyAdmin的SQL視窗內輸入「 select birthdate,year(birthdate) as year,quarter(birthdate) as quarter,month(birthdate) as month,monthname(birthdate) as monthname from employees; 」。 [...]]]></description>
		<wfw:commentRss>http://businesswing.net/webdesign/php-date_of_the_query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>第十四章  多個資料表查詢與變更資料</title>
		<link>http://businesswing.net/webdesign/php-multiple_tables_query_and_change_data/</link>
		<comments>http://businesswing.net/webdesign/php-multiple_tables_query_and_change_data/#comments</comments>
		<pubDate>Wed, 18 May 2011 09:14:26 +0000</pubDate>
		<dc:creator>bwingnet</dc:creator>
				<category><![CDATA[網頁程式PHP]]></category>
		<category><![CDATA[網頁設計]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://businesswing.net/?p=2063</guid>
		<description><![CDATA[上一章我們已經學習如何在一個資料表內進行資料查詢，但如果資料放在兩個資料表內，且同時要做搜尋，那該怎麼辦呢？另外，想要新增、刪除、更新資料，又該如何呢？本章將進一步說明如何於兩個資料表內進行查詢及進行新增、刪除與更新。 在進行各種SQL動作查詢之前，請您開啟「phpMyAdmin」，檢查「pcschool」資料庫內是否有employees、job、duty這幾個資料表，這幾個資料表將於本章用到，請務必點選光碟內「13」資料夾「SQL」資料夾，匯入這幾個資料表。 14-1 多個資料表查詢 您可以使用「inner join」的語法將兩個資料表內相同的資料列出，例如您想查詢「employees」資料表及「job」資料表的「employeeid」相同下的「employees.firstname, employees.city, job.title」這幾個欄位內容，而兩個資料表內都有九筆資料。您可於在「phpMyAdmin」內挑選「pcschool」資料庫後點選右上方的「SQL」，輸入「select employees.firstname, employees.city, job.title from employees inner join job on employees.employeeid = job.employeeid;」後執行。 【圖1、兩個資料表進行inner join查詢】 您會看到記錄內少了一筆紀錄，這是怎麼回是呢？其實是資料內有一筆資料欄位是「NULL」造成的。分別查閱「employees」資料表及「job」資料表內容就會發現有一筆資料無法對應。 【圖2、查尋job資料表內容，並與employees資料表進行資料比對】 【圖3、查尋employees資料表內容，並與job資料表進行資料比對】 資料內容為NULL代表沒有內容，在MySQL內其實蠻常見的。如果要顯示全部資料，包涵沒有內容的資料，請改用「left join」的方式連結兩個資料表，基本語法為「select 資料表. 欄位 from 主要資料表 left join 對應資料表 on 主要資料表.欄位=對應資料表.欄位」。例如您想查「當job資料表employeeid與employees資料表的employeeid相同時的employees.firstname、 employees.city與job.title內容，請在「phpMyAdmin」內挑選「pcschool」資料庫後點選右上方的「SQL」，輸入「select employees.firstname, employees.city, job.title,employees.employeeid as employees_id ,job.employeeid as job_id from employees left join job on employees.employeeid = job.employeeid;」後執行。 【圖4、以employees資料表為主對應到job資料表進行查詢】 [...]]]></description>
		<wfw:commentRss>http://businesswing.net/webdesign/php-multiple_tables_query_and_change_data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>13-5 本章中使用到的MySQL函數整理</title>
		<link>http://businesswing.net/webdesign/php-mysql_function_of_order/</link>
		<comments>http://businesswing.net/webdesign/php-mysql_function_of_order/#comments</comments>
		<pubDate>Tue, 17 May 2011 09:38:19 +0000</pubDate>
		<dc:creator>bwingnet</dc:creator>
				<category><![CDATA[網頁程式PHP]]></category>
		<category><![CDATA[網頁設計]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://businesswing.net/?p=2031</guid>
		<description><![CDATA[MySQL的函數可分為Procedure Function、Date Time Functions、Aggregate Functions、Control Flow Functions、Encryption Compression Functions、Math Numeric Functions、Miscellaneous Functions、String Functions等幾類，但這不是本書介紹的範圍，所以將在部落格內說明，如果各位讀者捧場，就會安排至下一本書內介紹。 這裡整理本章中已使用過的MySQL函數，讓各位方便檢索 【表5、本章使用的MySQL函數整理】 語法 說明 出現章節 curdate( ) 取得現在的日期 13-1-2 As的使用 year( ) 取得日期中的「年」資訊 13-1-2 As的使用 concat( ) 函數進行字串合併 13-1-2 As的使用 rand( ) 產生亂數 13-1-4 限制筆數 count( ) 計算總筆數 13-3 集合函數 count(distinct 欄位) 不重複資料的總筆數 13-3 集合函數 max( ) 最大值 13-3 集合函數 min( ) [...]]]></description>
		<wfw:commentRss>http://businesswing.net/webdesign/php-mysql_function_of_order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>13-4 分組查詢與分組條件搜尋</title>
		<link>http://businesswing.net/webdesign/php-grouping_conditions_for_the_search_query/</link>
		<comments>http://businesswing.net/webdesign/php-grouping_conditions_for_the_search_query/#comments</comments>
		<pubDate>Tue, 17 May 2011 09:31:03 +0000</pubDate>
		<dc:creator>bwingnet</dc:creator>
				<category><![CDATA[網頁程式PHP]]></category>
		<category><![CDATA[網頁設計]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://businesswing.net/?p=2026</guid>
		<description><![CDATA[SQL查詢語法內也可將資料進行分組，並於分組之後進行資料篩選。SQL語法於資料分組前與分組後均可篩選，這之間的差異將於本節作介紹說明。 13-4-1 分組查詢 當您找尋資料時，資料可以分組的方式進行查詢，語法結構如下： select 欄位，集合函數欄位 from 資料表 group by 分組欄位 請您於「customers」依據city進行分組，並輸出city欄位內容及每一組的總數，您可於SQL語法內輸入「 select city,count(*) as total from customers group by city; 」 後執行，您可看到執行的結果。 【圖37、select將city欄位分組後計算總數】 分組之後，若您想知道屬於這一群組的各資料某欄位內容，且希望值集中在一個欄位空間內，例如您想調查每一筆country內有多少個companyname，我們可使用group_concat( )函數將群組資料合併於一個欄位內顯示，請您輸入「 select country,group_concat(companyname) from customers group by country; 」後執行。 【圖38、select查詢依據群組分類，並將資料集中在一個欄位內】 13-4-2 分組後資料篩選 分組之後也可做資料的分析過濾，我們可於group by之後加入having進行條件分析，語法結構如下： select 欄位，集合函數欄位 from 資料表 group by 分組欄位 having 條件 例如您想查詢「customers」資料表內有哪些城市（city欄位）及分別有多少個，這時您會使用「 select city, count( city ) as [...]]]></description>
		<wfw:commentRss>http://businesswing.net/webdesign/php-grouping_conditions_for_the_search_query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>13-3 集合函數</title>
		<link>http://businesswing.net/webdesign/php-mysql_aggregate_functions/</link>
		<comments>http://businesswing.net/webdesign/php-mysql_aggregate_functions/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 09:55:55 +0000</pubDate>
		<dc:creator>bwingnet</dc:creator>
				<category><![CDATA[網頁程式PHP]]></category>
		<category><![CDATA[網頁設計]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://businesswing.net/?p=2022</guid>
		<description><![CDATA[前面我們所檢索的資料為一筆一筆的資料，可是如果想要查詢一群資料內的資訊，比如說總數、最大值、最小值、平均與總和，那該怎麼辦呢？MySQL提供了幾個查詢一群資料資訊的函數給我們使用： 【表4、查詢Select語法內的集合函數】 函數名稱 說明 count( ) 計算總筆數 count(distinct 欄位) 不重複資料的總筆數 max( ) 最大值 min( ) 最小值 avg( ) 平均 sum( ) 總合 13-3-1 集合函數的使用 您可先進行總筆數的查詢。例如您想瞭解「customers」」資料表內共有多少筆資料，請輸入「select count( * ) as total from customers; 」，就會列出總筆數。 【圖31、select查詢總筆數】 「*」代表任意欄位，如果指定欄位，而該欄位有Null值，那會如何呢？想瞭解「customers」資料表內「region」共有幾筆資料，請輸入「select count( region ) from customers; 」，您會發現到列出的筆數會比較少，因為這一個欄位有Null值，所以資料筆數會減少。 【圖32、select查詢總筆數，但筆數甚少，這是因為這個欄位有NULL值】 集合函數是一群資料中取出資料，所以不能跟「每一筆紀錄」一起取值，例如您想取得「customers」資料表內「region」共有幾筆資料及列出資料表內「contactname」欄位的資料，若您以「select contactname,count( region ) from customers」語法執行，會產生錯誤訊息。 【圖33、select查詢使用集合函數時不能跟每一筆記錄一起取值】 當我們想要知道「employees」資料表內總共有幾個city，希望統計時過濾重複的資料，那您應該在計算總數之前，使用distinct過濾，所以請以「select count(distinct city) from employees;」語法執行就可以知道資料表內有哪些不重複的城市數量。 【圖34、select查詢總筆數之前先使用distinct函數確認每一筆資料都是不重複】 [...]]]></description>
		<wfw:commentRss>http://businesswing.net/webdesign/php-mysql_aggregate_functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>13-2 where條件分析</title>
		<link>http://businesswing.net/webdesign/php-mysql_where/</link>
		<comments>http://businesswing.net/webdesign/php-mysql_where/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 09:33:45 +0000</pubDate>
		<dc:creator>bwingnet</dc:creator>
				<category><![CDATA[網頁程式PHP]]></category>
		<category><![CDATA[網頁設計]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://businesswing.net/?p=2017</guid>
		<description><![CDATA[我們並不一定每一次都要將表格內的資料都完全抓出。在許多時候，我們需要選擇性地抓資料，這時就得設定查詢條件。SQL語法內可使用WHERE指令設定各種條件。這個指令的語法如下： select 欄位名稱1,欄位名稱2 from 資料表格名稱 where 查詢條件 order by排序欄位 limit限制筆數 只有符合where條件的紀錄，才會被選取。條件的內容，通常是以欄位來比對某特定的值。請您注意如果比對的值，其資料型態不是數值時，請您要在前後加上單引號。 13-2-1 條件的判斷 數值資料可使用以下的比較運算子： 【表2、select查詢時數值條件的判斷】 運算子 意義 &#60; 小於 = 等於 &#62; 大於 &#60;= 小於等於 &#62;= 大於等於 &#60;&#62; 不等於 between … and 在兩個數字之間 在此舉幾個例子，例如當您想要檢索「employees」資料表內「employeeid」、「firstname」」這幾個欄位的內容，條件為「employeeid大於等於3」，請輸入「select employeeid,firstname from employees where (employeeid >= 3);」就可以檢索出employeeid大於等於3的資料。 【圖20、select查詢時設定條件】 13-2-2 集合的比對判斷 當我們要判斷資料是否為一群資料內的項目，我們可用「in」或「not in」來作分析。而這兩者不同的地方是，「in」代表「是否在一個集合裡」，「not in」代表「是否不在一個集合裡」。 假設您要檢索「employees」資料表內「employeeid」為2、4、9的firstname欄位的內容，請輸入「select employeeid,firstname from employees where (employeeid in(2,4,9));」就可以檢索出employeeid為2、4、9的資料。 【圖21、select查詢時where內使用in語法設定條件】 [...]]]></description>
		<wfw:commentRss>http://businesswing.net/webdesign/php-mysql_where/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>13-1-2  As的使用</title>
		<link>http://businesswing.net/webdesign/php-mysql_as/</link>
		<comments>http://businesswing.net/webdesign/php-mysql_as/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 09:07:07 +0000</pubDate>
		<dc:creator>bwingnet</dc:creator>
				<category><![CDATA[網頁程式PHP]]></category>
		<category><![CDATA[網頁設計]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://businesswing.net/?p=2015</guid>
		<description><![CDATA[如果您希望檢索出來的欄位名稱不同，請在檢索時在欄位名稱後面加上「as 檢索時的欄位名稱」，例如我們希望查詢「employees」資料表內「firstname」、「lastname」這兩個欄位的內容，但「firstname」顯示為「f」，而「lastname」顯示為「l」，請您於「SQL」選項輸入「select firstname as f, lastname as l from employees;」，查詢結果的欄位名稱就會變成「f」與「l」。 【圖5、select查詢後另外命名】 若我們查詢「products」資料表內「productname」、「unitprice」與「unitsinstock」這三個欄位的內容，但希望每一個產品能計算出總價，也就是「unitprice」乘以「unitsinstock」，該怎麼處理呢？您可檢索出「unitprice」與「unitsinstock」欄位，後於PHP內做乘法計算，但現在MySQL內可直接計算後以「as」語法替欄位命名，以此為例，我們可以增加一個欄位「unitprice * unitsinstock as total」，完整的SQL語法為「select productname, unitprice ,unitsinstock ,unitprice * unitsinstock as total from products;」，您可看到查詢時就可顯示出總價，PHP語法內就不需要再做計算，這樣是不是很方便呢？ 【圖6、select查詢時可加入計算式】 除了數值資料可做計算外，日期時間資料也可這樣做。現在我想知道「employees」資料表內員工姓名（「firstname」欄位）、雇用日期（「hiredate」欄位）及到職幾年。我們可於MySQL內使用curdate( )函數取得現在的日期，使用year( )函數取得日期中的「年」資訊，再以as的語法命名欄位名稱，所以您可於「SQL」選項輸入「select firstname,hiredate,curdate() as nowdate,(year(curdate())-year(hiredate)) as years from employees;」，查詢結果的內容將會計算出您所想要的結果。 【圖7、select查詢現在的日期與計算年的差異】 查詢時既然可以計算數值資料與日期資料，也可做文字資料的變化，例如我們希望查詢「employees」資料表內「firstname」、「lastname」這兩個欄位的內容，但希望「firstname」、「lastname」這兩個欄位能合併在一起顯示，請使用MySQL的concat( )函數進行字串合併，請輸入「select firstname,lastname,concat(firstname, "-- ",lastname) as yourname from employees;」。 【圖8、select查詢時將資料合併顯示】 MySQL提供的函數種類很多，限於篇幅無法一一介紹，筆者將於部落格上做整理介紹與相關討論。 13-1-3 排序 當我們查詢「employees」資料表內「firstname」、「lastname」這兩個欄位的所有內容時，您會發現到資料沒有依照字母順序，我們可以於select語法最後加上「order by 欄位名稱 asc&#124;desc」的方式進行排序。 [...]]]></description>
		<wfw:commentRss>http://businesswing.net/webdesign/php-mysql_as/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>第十三章  SQL語法查詢與MySQL函數運用</title>
		<link>http://businesswing.net/webdesign/sql-syntax_and_mysql-function/</link>
		<comments>http://businesswing.net/webdesign/sql-syntax_and_mysql-function/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 08:49:48 +0000</pubDate>
		<dc:creator>bwingnet</dc:creator>
				<category><![CDATA[網頁程式PHP]]></category>
		<category><![CDATA[網頁設計]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://businesswing.net/?p=1968</guid>
		<description><![CDATA[當我們想利用查詢、新增、刪除、更新mysql裡的資料，使用的語法就是SQL語法。SQL是「Structured Query Language」 的縮寫，簡單的說，SQL是一種與資料庫溝通的共通語言， 它是1970年由當時在IBM工作的 E.F. Codd針對關聯式模型 ( relational model )所建構出來的資料庫理論，也因此有了所謂關聯式資料庫的系統，但在發展的初期，由於各種關聯式資料庫系統廠商的 SQL語法沒有統一，對於使用者產生很大的困擾，後來才慢慢制定出SQL的標準化。 SQL語法可以分為三類。第一類稱之為「資料定義語言（Data Definition Language，DDL）」，DDL用於建立、更改或刪除 table、schema、domain、index 與 view 。主要指令為CREATE、ALTER 與 DROP。第二類稱之為「資料操作語言（Data Manipulation Language，DML）」，DML用於資料的操作。主要指令為SELECT、INSERT、UPDATE 和 DELETE。第三類稱之為「資料控制語言（Data Control Language，DCL）」，DCL 提供資料庫的安全性。主要指令為COMMIT、ROLLBACK、GRANT 和 REVOKE。 雖然現在每一個資料庫的SQL語法仍有差異，例如access與mysql在查詢時使用的萬用字元符號，access使用的是*，而mysql使用的是%，但大致上每一個資料庫都會依循標準的SQL語法作業。本章我們主要瞭解DML的使用，當PHP與MySQL連線成功後就可以做新增、刪除、更新、查詢的動作。在操作查詢語法之前，請您先建立「pcschool」資料庫並點選後，再請將「13」資料夾內的「sql.sql」載入到資料庫，如對於資料載入操作不熟悉，請參考上一章的說明。接著請開啟phpMyAdmin網頁，點選「pcschool」資料庫，再請點選右上角的「SQL」選項就可看見一個可輸入SQL語法的畫面。本章介紹的查詢語法，將於phpMyAdmin的SQL畫面內操作。 13-1 資料庫基本查詢 當我們建立好資料庫，並且輸入若干資料後，「查詢」會是經常操作的動作，所以一開始我們就來瞭解查詢語法。而查詢語法也是SQL中最複雜的語法。查詢語法規則如下： 語法內使用粗體字代表這是查詢語法內的關鍵字；而中括弧[ ]代表選擇性的選項，若不寫則依照原有設定；斜體字代表這裡將輸入字串。 上述語法的說明如下： 【表1、資料表查詢語法】 語法 說明 select 查詢 distinct 不重複的欄位 column_list 欄位列表，若不挑選欄位則用*代表 select [distinct] column_list 查詢哪些欄位資料，可加入不重複的欄位設定，若不挑選欄位可用*代表 from table_list 從哪一個資料表查詢 where [conditions] [...]]]></description>
		<wfw:commentRss>http://businesswing.net/webdesign/sql-syntax_and_mysql-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>12-5  終端機指令進行資料匯出與匯入</title>
		<link>http://businesswing.net/webdesign/php-cmd_data_export_and_import/</link>
		<comments>http://businesswing.net/webdesign/php-cmd_data_export_and_import/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 09:10:27 +0000</pubDate>
		<dc:creator>bwingnet</dc:creator>
				<category><![CDATA[網頁程式PHP]]></category>
		<category><![CDATA[網頁設計]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://businesswing.net/?p=1958</guid>
		<description><![CDATA[phpMyAdmin雖可備份各種資料庫，但只能手動方式備份，無法作排程備份。而且匯入資料時會有檔案大小限制，MySQL有提供其他匯出與匯入的指令嗎？ mysqldump是MySQL的匯出指令，而mysql是匯入的指令，不論是Windows或Linux環境都有這個指令。這兩個指令執行時不需進入MySQL終端機操作環境，在作業系統所提供的終端機模式內就可以使用，且這兩個指令可搭配Windows或Linux相關工具，做定時的備份或還原。 12-5-1 mysqldump做資料表資料匯出 mysqldump是資料庫內資料匯出的語法，基本的語法結構為 mysqldump -u帳號 -p密碼 [參數] 資料庫名稱 [資料表名稱] > SQL檔案 [參數]及[資料表名稱] 是非必要的項目。 例如我們在此匯出「pcschool」這一個資料庫內所有資料表欄位與內容：「mysqldump –uroot -pphpmysql pcschool >pcschool.sql」，您可開啟pcschool.sql，您會看到所有資料表欄位與內容。 【圖18、執行mysqldump後可看到所有資料表結構與內容】 只是資料匯出時只寫在一行敘述內，日後維護資料蠻不方便的，因此您可以加上「&#8211;skip-opt」參數，讓資料都能逐筆分行列出：「mysqldump -uroot -pphpmysql --skip-opt pcschool >pcschool2.sql」。 【圖19、執行mysqldump時加上「&#8211;skip-opt」參數，讓資料都能逐筆分行列出內容】 若要匯出一個資料表，請在資料庫名稱後面以空格方式作間隔加上資料表名稱。 例如我們匯出「pcschool」這一個資料庫內「student_utf8」資料表：「mysqldump -uroot -pphpmysql pcschool student_utf8 >pcschool3.sql」。 【圖20、執行mysqldump時於資料庫後加上資料表名稱就可匯出一個資料表結構與內容】 雖然只匯出指定資料表的欄位與內容，但內容只寫在一行敘述內，所以您可以加上「&#8211;skip-opt」參數，讓資料都能逐筆分行列出。所以這個參數可搭配不同的資料庫或資料表匯出：「mysqldump -uroot -pphpmysql --skip-opt pcschool student_utf8 >pcschool4.sql」 【圖21、執行mysqldump時加上分行選項及資料庫後加上資料表名稱就可匯出一個資料表結構與內容】 若要匯出多個資料表，請在資料庫名稱後面以空格方式作間隔加上資料表名稱即可。例如我們匯出「pcschool」這一個資料庫內「student_utf8」與「list」兩個資料表： 「mysqldump -uroot -pphpmysql pcschool student_utf8 list >pcschool5.sql」 12-5-2 mysqldump只匯出資料表結構或資料表內容 若只想匯出資料表的結構，請加入「&#8211;no-data」參數，例如匯出「pcschool」這一個資料庫內所有資料表的結構：「mysqldump [...]]]></description>
		<wfw:commentRss>http://businesswing.net/webdesign/php-cmd_data_export_and_import/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

