//php the_content_rss('', FALSE, '', 68); ?>
先月、とあるシステムをPostgreSQL 8.1.3→PostgreSQL 9.1.2にアップグレードしたら、既存システムが動かなくなった。
よく調べてみるとSQLのJoin部分のKeyの型がcharacterだと接続エラーになっていました。
解決方法
で、単純に下記のSQLで型を変更しようと思ったのですが、場所によっては下記のSQLでは型変更ができないところがありました。
ALTER TABLE toiawase ALTER COLUMN kokyaku_id TYPE integer USING kokyaku_id::integer;
解決方法(IndexやViewがある場合)
また調べてみると変更しようとしたKeyがIndexやViewの中でも使用されていることが判明
なので、変更対象のKeyが使用されているIndexやViewをいったん削除して、上記SQLを再度実行して、その後に、削除したIndexやViewを復元させて、
事無きを得ました。ちゃんちゃん
#Indexの削除
DROP INDEX name toiawase_Index;
#型の変更
ALTER TABLE toiawase ALTER COLUMN kokyaku_id TYPE integer USING kokyaku_id::integer;
#Indexの作成
CREATE INDEX toiawase_Index ON toiawase USING btree (kokyaku_id);
//php the_content_rss('', FALSE, '', 68); ?>
I often use postgres server,so sometimes I have to make testing environment for postgres in my windows pc.
So I want to write how to make testing environment about Postgres for my memo.

First Step
Please login postgres server, and then you have to change user what this user is postgres user.
And I use pg_dump.
# pg_dump -f filename.sql.gz -Z 1 -c database-name
-f to write file about output.
-Z。。Number this is level of compression.
-c it is cleaning for schema.
Second Step
You get dump file from server.And then you decompress file.
Third Step
You install postgres in your windows PC. Please check Postgres sites.
Fourth Step
Please copy dump file to there.
\Program Files\PostgresSQL\8.3\bin\
And please open command prompt and write this command.
cd \Program Files\PostgresSQL\8.3\bin\
psql dbname < dumpfile
That's all!!!
And if you see these message.Please make user on for postgres.
psql: FATAL: role "・譯シ・カフセ" does not exist、ネクタ、??ソ、饅r
Or
please change user what this user is postgres user.
psql -u
//php the_content_rss('', FALSE, '', 68); ?>
pg_dumpは
pg_dump database_name > database_name.sql
を実行すればできると、あるが実際はいろいろと気をつけないことが、たくさんあるのでそのメモ
その一、ユーザの準備
postgresでDBを作成しているなら、postgresユーザがいります。
useradd -d /home/postgres/ postgres
このときに、ホームディレクトリーも作っておきます。
その二、ファイルの準備
先ほど上のつくったホームディレクトリーの中にdatabase_name.sqlのファイルを作っておきます。
touch database_name.sql
その三、bushが引けてない場合があるのでlocateでpg_dumpを調べてひいいておきましょう。
その四、いざ実行
[postgres@www postgres]$ pg_dump database_name.sql > database_name.sql
//php the_content_rss('', FALSE, '', 68); ?>
今までのLIKE検索の仕方
( company LIKE '%".$word."%' OR address LIKE '%".$word."%' OR owner LIKE '%".$word."%' OR url LIKE '%".$word."%' OR title LIKE %".$word."%')";
↓
こうすればよかったんですね。
(company || address || owner || url || title ILIKE ('%".$value."%'))";
//php the_content_rss('', FALSE, '', 68); ?>
//Postgresのエスケープ
pg_escape_string($str);
//Mysqlのエスケープ
mysql_escape_string($str);