TopMovable TypeMySQL > MySQLでエントリーのフィールドサイズを拡張する
News
各種ブログテンプレート
2005年6月22日

エントリー本文

MySQLでエントリーのフィールドサイズを拡張する

Posted at June 22,2005 11:58 PM
Category:[MySQL]
Tag:[, , , , ]

MySQLではエントリーのデータ型に「TEXT型」というものを用いており、最大65535 バイトまで格納することができます。で、このサイズを超える場合、当然のことながらDBに適正に保存することができません(最大長に入らない部分が切り捨てられます。)。実は当サイトを Berkeley DB から MySQL に移行した際、テンプレートデータを記したエントリーが途中で途切れてしまい、調べているうちに上記の原因であることが判明しました。
ということで、MySQLでのフィールドサイズの拡張方法です。インストール前での実行方法ですので、その点は予めご了承ください。

Movable Type インストールアーカイブに含まれている schemas/mysql.dump を任意のエディタで開いて下記のように修正します。

create table mt_entry (
    entry_id integer not null auto_increment primary key,
    entry_blog_id integer not null,
    entry_status tinyint not null,
    entry_author_id integer not null,
    entry_allow_comments tinyint,
    entry_allow_pings tinyint,
    entry_convert_breaks varchar(30),
    entry_category_id integer,
    entry_title varchar(255),
    entry_excerpt text,
    entry_text textmediumtext,
    entry_text_more text,
    entry_to_ping_urls text,
    entry_pinged_urls text,
    entry_keywords text,
    entry_tangent_cache text,
    entry_created_on datetime not null,
    entry_modified_on timestamp not null,
    entry_created_by integer,
    entry_modified_by integer,
    entry_basename varchar(50) not null,
    index (entry_blog_id),
    index (entry_status),
    index (entry_author_id),
    index (entry_created_on),
    index (entry_basename)
);

mediumtext は最大長 16777215 バイトです。ちなみに longtext というものもあり、こちらは最大長 4294967295 バイトです。
テンプレートのフィールドサイズを拡張する場合は、同じファイル内の下記の部分を変更します(多分)。

create table mt_template (
    template_id integer not null auto_increment primary key,
    template_blog_id integer not null,
    template_name varchar(50) not null,
    template_type varchar(25) not null,
    template_outfile varchar(255),
    template_rebuild_me tinyint default 1,
    template_text textmediumtext,
    template_linked_file varchar(255),
    template_linked_file_mtime varchar(10),
    template_linked_file_size mediumint,
    template_created_on datetime not null,
    template_modified_on timestamp not null,
    template_created_by integer,
    template_modified_by integer,
    template_build_dynamic tinyint,
    unique (template_blog_id, template_name),
    index (template_type)
);

修正した後、Movable Type をインストールすることで指定したサイズでDBが作成されます。

Posted by yujiro
この記事を読んだ人はこんな記事も読んでいます
関連記事
人気エントリー
Hatena Hot Entries
Hatena Entries
トラックバックURL


コメントする
greeting

*必須



ご質問のコメントの回答については、内容あるいは多忙の場合、1週間以上かかる場合があります。また、すべてのご質問にはお答えできない可能性があります。予めご了承ください。

太字 イタリック アンダーライン ハイパーリンク 引用
[サインインしない場合はここにCAPTCHAを表示します]

コメント投稿後にScript Errorや500エラーが表示された場合は、すぐに再送信せず、ブラウザの「戻る」ボタンで一旦エントリーのページに戻り(プレビュー画面で投稿した場合は、投稿内容をマウスコピーしてからエントリーのページに戻り)、ブラウザをリロードして投稿コメントが反映されていることを確認してください。

コメント欄に(X)HTMLタグやMTタグを記述される場合、「<」は「&lt;」、「>」は「&gt;」と入力してください。例えば「<$MTBlogURL$>」は「&lt;$MTBlogURL$&gt;」となります(全て半角文字)

Now loading...
Introduction
Entries of this Category
Recent Entries
Recent Comments
Recent Trackbacks
QRcode

現在停止中です
携帯電話からこのQRcodeを撮影することで携帯用URLを取得することができます

URI for cellular phones
ギターに入った猫
Styles
Font Size
Default
For defective color vision
Gray Scale
RGB Color
Search this site

このブログをメールで購読する by:FeedBurner

loading ...
Categories
Monthly Archives
BlogPeople
Now loading...
Syndicate this site
FeedBurner(RSS1.0/RSS2.0/Atom)
Counter
これまでのアクセス
クリエイティブ・コモンズ・ライセンス
Powered by
Movable Type 4.261
 
List Me!