Manual:SQL パッチ ファイル

From MediaWiki.org
Jump to: navigation, search
This page is a translated version of the page Manual:SQL patch file and the translation is 54% complete.

Other languages:
English • ‎español • ‎français • ‎日本語 • ‎polski • ‎português • ‎português do Brasil

You might write an SQL file either for a schema change in the core (see Development_policy#Database_patches, Manual:DatabaseUpdater.phpManual:DatabaseUpdater.php) or for an extension (see Manual:Hooks/LoadExtensionSchemaUpdatesManual:Hooks/LoadExtensionSchemaUpdates).

テーブルを作成するための SQL ファイルは、以下のようになるでしょう:

BEGIN;
 
CREATE TABLE /*_*/foo_bar(
-- Primary key
fb_id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
-- user.user_id of the user who foobared the wiki
fb_user INT UNSIGNED NOT NULL,
-- user.user_text of the user who foobared the wiki
fb_user_text VARCHAR(256),
-- Timestamp of when the wiki was foobared
fb_timestamp varbinary(14) NOT NULL default NULL ''
)/*$wgDBTableOptions*/;

CREATE INDEX /*i*/fb_user ON /*_*/foo_bar (fb_user);
CREATE INDEX /*i*/fb_user_text ON /*_*/foo_bar (fb_user_text);
COMMIT;

変数の置換

/*_*/$wgDBprefixManual:$wgDBprefix に置換されます。 /*i*/ will be replaced with an index prefix. /*$wgDBTableOptions*/$wgDBTableOptionsManual:$wgDBTableOptions の値に置換されます。 These three need to be used in patch files, as in the example above. There are other variable replacements but they are not used in practice. See the documentation of DatabaseBase::replaceVars() for the full list.

外部リンク

データベースManual:Database layout エンジン: MySQL/MariaDBManual:MySQLOracleManual:OraclePostgreSQLManual:PostgreSQLSQLiteManual:SQLite
技術的な説明文書: スキーマManual:Database layout (テーブルCategory:MediaWiki database tables) – API property associationsAPI:Database field and API property associationsフィールド接頭辞Database field prefixes他のフィールドへの主キーの格納Manual:Primary key storage in other fieldsウィキメディアの拡張機能のテーブルCategory:Wikimedia extension database tables
設定の構成: 設定Manual:Configuration_settings#Database_settings共有Manual:Shared database
開発: アクセスManual:Database access最適化Database optimization方針Development policy#Database_patchesアップデーターManual:DatabaseUpdater.php拡張機能のスキーマの更新Manual:Hooks/LoadExtensionSchemaUpdatesパッチ ファイルManual:SQL patch file
コアのテーブル: archivecategorycategorylinkschange_tagconfigexternallinksfilearchivehitcounterimageimagelinksinterwikiiwlinksipblocksjobl10n_cachelanglinkslogginglog_searchmsg_resourcemsg_resource_linksmodule_depsobjectcacheoldimagepagepagelinkspage_propspage_restrictionsprotected_titlesquerycachequerycachetwoquerycache_inforecentchangesredirectrevisionsearchindexsitessite_identifiers - site_statstag_summarytemplatelinkstexttranscacheupdateloguploadstashuseruser_former_groupsuser_groupsuser_newtalkuser_propertiestag_summaryvalid_tagwatchlist