Manual:SQL パッチ ファイル
From MediaWiki.org
You might write an SQL file either for a schema change in the core (see Development_policy#Database_patches, Manual:DatabaseUpdater.php ) or for an extension (see Manual: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;
変数の置換
/*_*/
は $wgDBprefix に置換されます。 /*i*/
will be replaced with an index prefix. /*$wgDBTableOptions*/
は $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.
外部リンク
- W3Schools, CREATE TABLE
- W3Schools, ALTER TABLE - 列の追加、変更、削除に使用されます
![]() |
エンジン: MySQL/MariaDB – Oracle – PostgreSQL – SQLite 技術的な説明文書: スキーマ (テーブル ) – API property associations – フィールド接頭辞 – 他のフィールドへの主キーの格納 – ウィキメディアの拡張機能のテーブル 設定の構成: 設定 – 共有 開発: アクセス – 最適化 – 方針 – アップデーター – 拡張機能のスキーマの更新 – パッチ ファイル コアのテーブル: archive – category – categorylinks – change_tag – config – externallinks – filearchive – hitcounter – image – imagelinks – interwiki – iwlinks – ipblocks – job – l10n_cache – langlinks – logging – log_search – msg_resource – msg_resource_links – module_deps – objectcache – oldimage – page – pagelinks – page_props – page_restrictions – protected_titles – querycache – querycachetwo – querycache_info – recentchanges – redirect – revision – searchindex – sites – site_identifiers - site_stats – tag_summary – templatelinks – text – transcache – updatelog – uploadstash – user – user_former_groups – user_groups – user_newtalk – user_properties – tag_summary – valid_tag – watchlist |
---|