Manual:SQL patch file/pt-br

From MediaWiki.org
Jump to: navigation, search
This page is a translated version of the page Manual:SQL patch file and the translation is 15% 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).

Exemplo

An SQL file to create a table might look something like this:

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;

Variable replacement

/*_*/ will be replaced with $wgDBprefixManual:$wgDBprefix. /*i*/ will be replaced with an index prefix. /*$wgDBTableOptions*/ will be replaced with the value of $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.

Links externos

Bancos de dadosManual:Database layout Gerenciadores: MySQL/MariaDBManual:MySQLOracleManual:OraclePostgreSQLManual:PostgreSQLSQLiteManual:SQLite
Documentação técnica: EsquemaManual:Database layout (tabelasCategory:MediaWiki database tables) – Associações de propriedades da APIAPI:Database field and API property associationsPrefixos de campoDatabase field prefixesPrimary key storage in other fieldsManual:Primary key storage in other fieldsTabelas de extensões da WikimediaCategory:Wikimedia extension database tables
Configuração: DefiniçõesManual:Configuration_settings#Database_settingsCompartilhamentoManual:Shared database
Desenvolvimento: AcessoManual:Database accessOtimizaçãoDatabase optimizationPolíticasDevelopment policy#Database_patchesAtualizaçãoManual:DatabaseUpdater.phpAtualizações de esquemas de extensõesManual:Hooks/LoadExtensionSchemaUpdatesArquivo de correçãoManual:SQL patch file
Tabelas de núcleo: archivecategorycategorylinkschange_tagconfigexternallinksfilearchivehitcounterimageimagelinksinterwikiiwlinksipblocksjobl10n_cachelanglinkslogginglog_searchmsg_resourcemsg_resource_linksmodule_depsobjectcacheoldimagepagepagelinkspage_propspage_restrictionsprotected_titlesquerycachequerycachetwoquerycache_inforecentchangesredirectrevisionsearchindexsitessite_identifiers - site_statstag_summarytemplatelinkstexttranscacheupdateloguploadstashuseruser_former_groupsuser_groupsuser_newtalkuser_propertiestag_summaryvalid_tagwatchlist