<?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>GANCHIKU.com &#187; SQL</title>
	<atom:link href="http://ganchiku.com/category/sql/feed" rel="self" type="application/rss+xml" />
	<link>http://ganchiku.com</link>
	<description>renewal, baby!</description>
	<lastBuildDate>Sun, 05 Feb 2012 12:32:58 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>REFERENCES table名 ON DELETE CASCADE ON UPDATE CASCADE</title>
		<link>http://ganchiku.com/2005/12/references_table_on_delete_cas.html</link>
		<comments>http://ganchiku.com/2005/12/references_table_on_delete_cas.html#comments</comments>
		<pubDate>Thu, 08 Dec 2005 14:18:13 +0000</pubDate>
		<dc:creator>shin</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.ganchiku.com/?p=23</guid>
		<description><![CDATA[SQLに関して少し詳しくなった。 タイトルにあるように。 外部キーとして参照されているときのカラムの削除や更新の際に、参照先のテーブルのカラム定義にON UPDADE とか ON DELETEとかカラムに定義しておくと、 &#8230; <a href="http://ganchiku.com/2005/12/references_table_on_delete_cas.html">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>SQLに関して少し詳しくなった。<br />
タイトルにあるように。</p>
<p>外部キーとして参照されているときのカラムの削除や更新の際に、参照先のテーブルのカラム定義にON UPDADE とか ON DELETEとかカラムに定義しておくと、一緒に、参照先のテーブルのキーとかも変更とか削除とかしてくれるのね。<br />
これ便利。<br />
いままで、参照されているものを消さなきゃいけないじゃん。とずっと思っていたけど、そんなことは全くもってないんだね。</p>
<p><a href="http://www.postgresql.jp/document/pg810doc/html/sql-createtable.html">CREATE TABLE</a><br />
つーわけで、以下抜粋。ON DELETEやON UPDATEで次のものを指定できる。</p>
<blockquote><p>
    NO ACTION</p>
<p>        削除もしくは更新が外部キー制約違反となることを示すエラーを発生します。制約が遅延可能な場合、何らかの参照行が存在する限り、このエラーは制約の検査時点で発生します。これはデフォルトの動作です。<br />
    RESTRICT</p>
<p>        削除もしくは更新が外部キー制約違反となることを示すエラーを発生します。検査が遅延できない点を除き、NO ACTIONと同じです。<br />
    CASCADE</p>
<p>        削除された行を参照している行は全て削除します。また、参照している列の値を、被参照列の新しい値にします。<br />
    SET NULL</p>
<p>        参照する列（複数可）をNULLに設定します。<br />
    SET DEFAULT</p>
<p>        参照する列（複数可）をそのデフォルト値に設定します。
 </p></blockquote>
<p>つか、本当は、もっともっとたくさんオプションがあるんだ。ぜんぜん使ってない。。。。ことはないか。<br />
<span id="more-23"></span><br />
CACADEって書いていた。CASCADEね。情けない。。。で、修正した。</p>
]]></content:encoded>
			<wfw:commentRss>http://ganchiku.com/2005/12/references_table_on_delete_cas.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

