<?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:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>zaru blog &#187; MySQL_PostgreSQL</title>
	<atom:link href="http://zaru.tofu-kun.org/category/mysql_postgresql/feed/" rel="self" type="application/rss+xml" />
	<link>http://zaru.tofu-kun.org</link>
	<description>Web系のこととかー。</description>
	<lastBuildDate>Fri, 18 Nov 2011 02:28:49 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/category/mysql_postgresql/feed/" />
		<item>
		<title>CakePHP+PostgreSQLで、relation &#8216;hoge&#8217; does not existって怒られたときの対処法</title>
		<link>http://zaru.tofu-kun.org/2011/04/18/cakephppostgresql%e3%81%a7%e3%80%81relation-hoge-does-not-exist%e3%81%a3%e3%81%a6%e6%80%92%e3%82%89%e3%82%8c%e3%81%9f%e3%81%a8%e3%81%8d%e3%81%ae%e5%af%be%e5%87%a6%e6%b3%95/</link>
		<comments>http://zaru.tofu-kun.org/2011/04/18/cakephppostgresql%e3%81%a7%e3%80%81relation-hoge-does-not-exist%e3%81%a3%e3%81%a6%e6%80%92%e3%82%89%e3%82%8c%e3%81%9f%e3%81%a8%e3%81%8d%e3%81%ae%e5%af%be%e5%87%a6%e6%b3%95/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 08:31:53 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[MySQL_PostgreSQL]]></category>
		<category><![CDATA[プログラミング_PHP]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=340</guid>
		<description><![CDATA[基本的に僕はCakePHP + MySQLの組み合わせで運用しているので、PostgreSQLでの運用経験がなく、基本的なところでつまずいてしまう。 今回は、データを save しようとしたら出たエラー「relation &#8216;hoge&#8217; does not exist」。実行しているSQLを確認すると…。 SELECT currval('hoge_did_sequence') as max あー、しまった。プライマリーキー用のシーケンス名が違うからか。というわけでモデルに var $sequence = '名前'; と設定してあげることで大丈夫です。]]></description>
			<content:encoded><![CDATA[<p>基本的に僕はCakePHP + MySQLの組み合わせで運用しているので、PostgreSQLでの運用経験がなく、基本的なところでつまずいてしまう。</p>
<p>今回は、データを save しようとしたら出たエラー「relation &#8216;hoge&#8217; does not exist」。実行しているSQLを確認すると…。</p>
<pre class="brush: sql; title: ;">SELECT currval('hoge_did_sequence') as max</pre>
<p>あー、しまった。プライマリーキー用のシーケンス名が違うからか。というわけでモデルに</p>
<pre class="brush: php; title: ;">var $sequence = '名前';</pre>
<p>と設定してあげることで大丈夫です。</p>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=340&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/04/18/cakephppostgresql%e3%81%a7%e3%80%81relation-hoge-does-not-exist%e3%81%a3%e3%81%a6%e6%80%92%e3%82%89%e3%82%8c%e3%81%9f%e3%81%a8%e3%81%8d%e3%81%ae%e5%af%be%e5%87%a6%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/04/18/cakephppostgresql%e3%81%a7%e3%80%81relation-hoge-does-not-exist%e3%81%a3%e3%81%a6%e6%80%92%e3%82%89%e3%82%8c%e3%81%9f%e3%81%a8%e3%81%8d%e3%81%ae%e5%af%be%e5%87%a6%e6%b3%95/" />
	</item>
		<item>
		<title>MySQLでコンソール上の表示結果を見やすくする方法</title>
		<link>http://zaru.tofu-kun.org/2011/02/22/mysql%e3%81%a7%e3%82%b3%e3%83%b3%e3%82%bd%e3%83%bc%e3%83%ab%e4%b8%8a%e3%81%ae%e8%a1%a8%e7%a4%ba%e7%b5%90%e6%9e%9c%e3%82%92%e8%a6%8b%e3%82%84%e3%81%99%e3%81%8f%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/</link>
		<comments>http://zaru.tofu-kun.org/2011/02/22/mysql%e3%81%a7%e3%82%b3%e3%83%b3%e3%82%bd%e3%83%bc%e3%83%ab%e4%b8%8a%e3%81%ae%e8%a1%a8%e7%a4%ba%e7%b5%90%e6%9e%9c%e3%82%92%e8%a6%8b%e3%82%84%e3%81%99%e3%81%8f%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 01:25:57 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[MySQL_PostgreSQL]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=312</guid>
		<description><![CDATA[ちょっとデータを見たい時に、コンソール上でMySQLに入って SELECT することって結構ありますよね。カラムが大量にある場合、出力結果の表組みが画面幅で改行されて非常に見えにくいものになってしまって、軽くイラッとくることが僕は多々あります。必要なカラムだけ指定すれば良いんだけど、それも面倒っていうときは、ページャーを指定すると幸せになれます。 通常のログイン $mysql -u root -p db_name ページャー指定してログイン $mysql --pager='less -S' -u root -p db_name これで、矢印キーでスクロール操作が可能です。 ちなみに、ページャーには less 以外にも more, cat [>filename] が使用できます。]]></description>
			<content:encoded><![CDATA[<p>ちょっとデータを見たい時に、コンソール上でMySQLに入って SELECT することって結構ありますよね。カラムが大量にある場合、出力結果の表組みが画面幅で改行されて非常に見えにくいものになってしまって、軽くイラッとくることが僕は多々あります。必要なカラムだけ指定すれば良いんだけど、それも面倒っていうときは、ページャーを指定すると幸せになれます。</p>
<h4>通常のログイン</h4>
<pre class="brush: bash; title: ;">
$mysql -u root -p db_name
</pre>
<h4>ページャー指定してログイン</h4>
<pre class="brush: bash; title: ;">
$mysql --pager='less -S' -u root -p db_name
</pre>
<p>これで、矢印キーでスクロール操作が可能です。</p>
<p>ちなみに、ページャーには less 以外にも more, cat [>filename] が使用できます。</p>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=312&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/02/22/mysql%e3%81%a7%e3%82%b3%e3%83%b3%e3%82%bd%e3%83%bc%e3%83%ab%e4%b8%8a%e3%81%ae%e8%a1%a8%e7%a4%ba%e7%b5%90%e6%9e%9c%e3%82%92%e8%a6%8b%e3%82%84%e3%81%99%e3%81%8f%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/02/22/mysql%e3%81%a7%e3%82%b3%e3%83%b3%e3%82%bd%e3%83%bc%e3%83%ab%e4%b8%8a%e3%81%ae%e8%a1%a8%e7%a4%ba%e7%b5%90%e6%9e%9c%e3%82%92%e8%a6%8b%e3%82%84%e3%81%99%e3%81%8f%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/" />
	</item>
		<item>
		<title>MySQL5.0から5.1へアップデートしたら#mysql50#って付いた件</title>
		<link>http://zaru.tofu-kun.org/2011/02/09/mysql5-0%e3%81%8b%e3%82%895-1%e3%81%b8%e3%82%a2%e3%83%83%e3%83%97%e3%83%87%e3%83%bc%e3%83%88%e3%81%97%e3%81%9f%e3%82%89mysql50%e3%81%a3%e3%81%a6%e4%bb%98%e3%81%84%e3%81%9f%e4%bb%b6/</link>
		<comments>http://zaru.tofu-kun.org/2011/02/09/mysql5-0%e3%81%8b%e3%82%895-1%e3%81%b8%e3%82%a2%e3%83%83%e3%83%97%e3%83%87%e3%83%bc%e3%83%88%e3%81%97%e3%81%9f%e3%82%89mysql50%e3%81%a3%e3%81%a6%e4%bb%98%e3%81%84%e3%81%9f%e4%bb%b6/#comments</comments>
		<pubDate>Wed, 09 Feb 2011 03:53:55 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[MySQL_PostgreSQL]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=291</guid>
		<description><![CDATA[yumの自動アップデートでMySQLが5.0から5.1へアップデートされたのだけど、なぜかデータベースへアクセス出来ない不具合が。データベース名を確認してみると… mysql&#62;show databases; +--------------------+ &#124; Database &#124; +--------------------+ &#124; #mysql50#db_name &#124; +--------------------+ あれ？データベース名の頭に「#mysql50#」なんてものが付いている…。調べてみると、どうやらデータベース名に「-」と半角ハイフンが入っている場合にそうなるみたい。 たとえば、MySQL 5.0 のデータベースの名前が a-b-c の場合、その名前には &#8216;-&#8217; 文字のインスタンスが含まれています。5.0 では、データベースディレクトリにも a-b-c という名前が付けられますが、必ずしもすべてのファイルシステムで安全とはいえません。MySQL 5.1 以降では、ファイルシステムに依存しないディレクトリ名を生成するために、同じデータベース名が a@002db@002dc としてエンコードされます。 MySQL インストールが旧バージョンから MySQL 5.1 以降にアップグレードされると、サーバーでは a-b-c などの古い形式の名前が #mysql50#a-b-c として表示されるため、#mysql50# の接頭辞を付けて名前を参照する必要があります。この場合は、UPGRADE DATA DIRECTORY NAME を使用して、データベースディレクトリ名を現在のコード化形式に再エンコードするようサーバーに明示的に指示します。 http://dev.mysql.com/doc/refman/5.1-olh/ja/alter-database.html 解決方法 #mysql_upgrade -u root と mysql_upgrade を実行すると自動的に修正してくれる。]]></description>
			<content:encoded><![CDATA[<p>yumの自動アップデートでMySQLが5.0から5.1へアップデートされたのだけど、なぜかデータベースへアクセス出来ない不具合が。データベース名を確認してみると…</p>
<pre class="brush: bash; title: ;">
mysql&gt;show databases;
+--------------------+
| Database           |
+--------------------+
| #mysql50#db_name   |
+--------------------+
</pre>
<p>あれ？データベース名の頭に「#mysql50#」なんてものが付いている…。調べてみると、どうやらデータベース名に「-」と半角ハイフンが入っている場合にそうなるみたい。</p>
<blockquote><p>
たとえば、MySQL 5.0 のデータベースの名前が a-b-c の場合、その名前には &#8216;-&#8217; 文字のインスタンスが含まれています。5.0 では、データベースディレクトリにも a-b-c という名前が付けられますが、必ずしもすべてのファイルシステムで安全とはいえません。MySQL 5.1 以降では、ファイルシステムに依存しないディレクトリ名を生成するために、同じデータベース名が a@002db@002dc としてエンコードされます。</p>
<p>MySQL インストールが旧バージョンから MySQL 5.1 以降にアップグレードされると、サーバーでは a-b-c などの古い形式の名前が #mysql50#a-b-c として表示されるため、#mysql50# の接頭辞を付けて名前を参照する必要があります。この場合は、UPGRADE DATA DIRECTORY NAME を使用して、データベースディレクトリ名を現在のコード化形式に再エンコードするようサーバーに明示的に指示します。<br />
<a href="http://dev.mysql.com/doc/refman/5.1-olh/ja/alter-database.html">http://dev.mysql.com/doc/refman/5.1-olh/ja/alter-database.html</a>
</p></blockquote>
<h3>解決方法</h3>
<pre class="brush: bash; title: ;">
#mysql_upgrade -u root
</pre>
<p>と mysql_upgrade を実行すると自動的に修正してくれる。</p>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=291&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/02/09/mysql5-0%e3%81%8b%e3%82%895-1%e3%81%b8%e3%82%a2%e3%83%83%e3%83%97%e3%83%87%e3%83%bc%e3%83%88%e3%81%97%e3%81%9f%e3%82%89mysql50%e3%81%a3%e3%81%a6%e4%bb%98%e3%81%84%e3%81%9f%e4%bb%b6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/02/09/mysql5-0%e3%81%8b%e3%82%895-1%e3%81%b8%e3%82%a2%e3%83%83%e3%83%97%e3%83%87%e3%83%bc%e3%83%88%e3%81%97%e3%81%9f%e3%82%89mysql50%e3%81%a3%e3%81%a6%e4%bb%98%e3%81%84%e3%81%9f%e4%bb%b6/" />
	</item>
		<item>
		<title>MySQLでコマンドから直接クエリを実行し、CSVファイルに保存する</title>
		<link>http://zaru.tofu-kun.org/2011/01/04/mysql%e3%81%a7%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%81%8b%e3%82%89%e7%9b%b4%e6%8e%a5%e3%82%af%e3%82%a8%e3%83%aa%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%97%e3%80%81csv%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab/</link>
		<comments>http://zaru.tofu-kun.org/2011/01/04/mysql%e3%81%a7%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%81%8b%e3%82%89%e7%9b%b4%e6%8e%a5%e3%82%af%e3%82%a8%e3%83%aa%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%97%e3%80%81csv%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 05:55:42 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[MySQL_PostgreSQL]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=273</guid>
		<description><![CDATA[mysqlコマンドを実行して、中にはいってからSQLを実行しても良いんだけど、ちょっとした事だったら面倒くさいし、シェルでワンライナーでいけるならそっちのが良いっていうときには -eオプションを使うと直接クエリを実行することができる。 $mysql -u root DBNAME -e &#34;クエリ&#34; これと、 into outfile を併用することでテーブルの中身をCSVファイルとして書き出すことができる。 $mysql -u root DBNAME -e &#34;select * from table into outfile '/tmp/output.csv' fields terminated by ',' enclosed by '\&#34;'&#34; PostgreSQLの場合は、PostgreSQLで一部分のデータのみダンプする方法を参照。]]></description>
			<content:encoded><![CDATA[<p>mysqlコマンドを実行して、中にはいってからSQLを実行しても良いんだけど、ちょっとした事だったら面倒くさいし、シェルでワンライナーでいけるならそっちのが良いっていうときには -eオプションを使うと直接クエリを実行することができる。</p>
<pre class="brush: bash; title: ;">
$mysql -u root DBNAME -e &quot;クエリ&quot;
</pre>
<p>これと、 into outfile を併用することでテーブルの中身をCSVファイルとして書き出すことができる。</p>
<pre class="brush: bash; title: ;">
$mysql -u root DBNAME -e
&quot;select * from table into outfile '/tmp/output.csv'
fields terminated by ',' enclosed by '\&quot;'&quot;
</pre>
<p>PostgreSQLの場合は、<a href="http://zaru.tofu-kun.org/2010/12/21/postgresql%E3%81%A7%E4%B8%80%E9%83%A8%E5%88%86%E3%81%AE%E3%83%87%E3%83%BC%E3%82%BF%E3%81%AE%E3%81%BF%E3%83%80%E3%83%B3%E3%83%97%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/">PostgreSQLで一部分のデータのみダンプする方法</a>を参照。</p>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=273&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/01/04/mysql%e3%81%a7%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%81%8b%e3%82%89%e7%9b%b4%e6%8e%a5%e3%82%af%e3%82%a8%e3%83%aa%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%97%e3%80%81csv%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/01/04/mysql%e3%81%a7%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%81%8b%e3%82%89%e7%9b%b4%e6%8e%a5%e3%82%af%e3%82%a8%e3%83%aa%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%97%e3%80%81csv%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab/" />
	</item>
	</channel>
</rss>
