tables.sql
来自「php 开发的内容管理系统」· SQL 代码 · 共 1,009 行 · 第 1/3 页
SQL
1,009 行
-- Experimental table definitions for MySQL 4.1 and 5.0 with-- explicit character set support. Not fully tested, may have-- surprises!---- TODO: Test various fields-- TODO: Anything else need to be moved to VARBINARY and BLOB?-- TODO: UCS-2 better than UTF-8?-- TODO: Find out how to get 4-byte UTF-8 chars into MySQL...-- An alternate UCS-2 that does UTF-16 conversion would work.-- TODO: Work on collation usage-- -------------------------------------------------------------- SQL to create the initial tables for the MediaWiki database.-- This is read and executed by the install script; you should-- not have to run it by itself unless doing a manual install.---- General notes:---- If possible, create tables as InnoDB to benefit from the-- superior resiliency against crashes and ability to read-- during writes (and write during reads!)---- Only the 'searchindex' table requires MyISAM due to the-- requirement for fulltext index support, which is missing-- from InnoDB.------ The MySQL table backend for MediaWiki currently uses-- 14-character CHAR or VARCHAR fields to store timestamps.-- The format is YYYYMMDDHHMMSS, which is derived from the-- text format of MySQL's TIMESTAMP fields.---- Historically TIMESTAMP fields were used, but abandoned-- in early 2002 after a lot of trouble with the fields-- auto-updating.---- The PostgreSQL backend uses DATETIME fields for timestamps,-- and we will migrate the MySQL definitions at some point as-- well.------ The /*$wgDBprefix*/ comments in this and other files are-- replaced with the defined table prefix by the installer-- and updater scripts. If you are installing or running-- updates manually, you will need to manually insert the-- table prefix if any when running these scripts.------ The user table contains basic account information,-- authentication keys, etc.---- Some multi-wiki sites may share a single central user table-- between separate wikis using the $wgSharedDB setting.---- Note that when a external authentication plugin is used,-- user table entries still need to be created to store-- preferences and to key tracking information in the other-- tables.--CREATE TABLE /*$wgDBprefix*/user ( user_id int(5) unsigned NOT NULL auto_increment, -- Usernames must be unique, must not be in the form of -- an IP address. _Shouldn't_ allow slashes or case -- conflicts. Spaces are allowed, and are _not_ converted -- to underscores like titles. See the User::newFromName() for -- the specific tests that usernames have to pass. user_name varchar(255) binary NOT NULL default '', -- Optional 'real name' to be displayed in credit listings user_real_name varchar(255) binary NOT NULL default '', -- Password hashes, normally hashed like so: -- MD5(CONCAT(user_id,'-',MD5(plaintext_password))), see -- wfEncryptPassword() in GlobalFunctions.php user_password tinyblob NOT NULL default '', -- When using 'mail me a new password', a random -- password is generated and the hash stored here. -- The previous password is left in place until -- someone actually logs in with the new password, -- at which point the hash is moved to user_password -- and the old password is invalidated. user_newpassword tinyblob NOT NULL default '', -- Note: email should be restricted, not public info. -- Same with passwords. user_email tinytext NOT NULL default '', -- Newline-separated list of name=value defining the user -- preferences user_options blob NOT NULL default '', -- This is a timestamp which is updated when a user -- logs in, logs out, changes preferences, or performs -- some other action requiring HTML cache invalidation -- to ensure that the UI is updated. user_touched char(14) binary NOT NULL default '', -- A pseudorandomly generated value that is stored in -- a cookie when the "remember password" feature is -- used (previously, a hash of the password was used, but -- this was vulnerable to cookie-stealing attacks) user_token char(32) binary NOT NULL default '', -- Initially NULL; when a user's e-mail address has been -- validated by returning with a mailed token, this is -- set to the current timestamp. user_email_authenticated CHAR(14) BINARY, -- Randomly generated token created when the e-mail address -- is set and a confirmation test mail sent. user_email_token CHAR(32) BINARY, -- Expiration date for the user_email_token user_email_token_expires CHAR(14) BINARY, -- Timestamp of account registration. -- Accounts predating this schema addition may contain NULL. user_registration CHAR(14) BINARY, PRIMARY KEY user_id (user_id), UNIQUE INDEX user_name (user_name), INDEX (user_email_token)) TYPE=InnoDB, DEFAULT CHARSET=utf8;---- User permissions have been broken out to a separate table;-- this allows sites with a shared user table to have different-- permissions assigned to a user in each project.---- This table replaces the old user_rights field which used a-- comma-separated blob.--CREATE TABLE /*$wgDBprefix*/user_groups ( -- Key to user_id ug_user int(5) unsigned NOT NULL default '0', -- Group names are short symbolic string keys. -- The set of group names is open-ended, though in practice -- only some predefined ones are likely to be used. -- -- At runtime $wgGroupPermissions will associate group keys -- with particular permissions. A user will have the combined -- permissions of any group they're explicitly in, plus -- the implicit '*' and 'user' groups. ug_group char(16) NOT NULL default '', PRIMARY KEY (ug_user,ug_group), KEY (ug_group)) TYPE=InnoDB, DEFAULT CHARSET=utf8;-- Stores notifications of user talk page changes, for the display-- of the "you have new messages" boxCREATE TABLE /*$wgDBprefix*/user_newtalk ( -- Key to user.user_id user_id int(5) NOT NULL default '0', -- If the user is an anonymous user hir IP address is stored here -- since the user_id of 0 is ambiguous user_ip varchar(40) NOT NULL default '', INDEX user_id (user_id), INDEX user_ip (user_ip)) TYPE=InnoDB, DEFAULT CHARSET=utf8;---- Core of the wiki: each page has an entry here which identifies-- it by title and contains some essential metadata.--CREATE TABLE /*$wgDBprefix*/page ( -- Unique identifier number. The page_id will be preserved across -- edits and rename operations, but not deletions and recreations. page_id int(8) unsigned NOT NULL auto_increment, -- A page name is broken into a namespace and a title. -- The namespace keys are UI-language-independent constants, -- defined in includes/Defines.php page_namespace int NOT NULL, -- The rest of the title, as text. -- Spaces are transformed into underscores in title storage. page_title varchar(255) binary NOT NULL, -- Comma-separated set of permission keys indicating who -- can move or edit the page. page_restrictions tinyblob NOT NULL default '', -- Number of times this page has been viewed. page_counter bigint(20) unsigned NOT NULL default '0', -- 1 indicates the article is a redirect. page_is_redirect tinyint(1) unsigned NOT NULL default '0', -- 1 indicates this is a new entry, with only one edit. -- Not all pages with one edit are new pages. page_is_new tinyint(1) unsigned NOT NULL default '0', -- Random value between 0 and 1, used for Special:Randompage page_random real unsigned NOT NULL, -- This timestamp is updated whenever the page changes in -- a way requiring it to be re-rendered, invalidating caches. -- Aside from editing this includes permission changes, -- creation or deletion of linked pages, and alteration -- of contained templates. page_touched char(14) binary NOT NULL default '', -- Handy key to revision.rev_id of the current revision. -- This may be 0 during page creation, but that shouldn't -- happen outside of a transaction... hopefully. page_latest int(8) unsigned NOT NULL, -- Uncompressed length in bytes of the page's current source text. page_len int(8) unsigned NOT NULL, PRIMARY KEY page_id (page_id), UNIQUE INDEX name_title (page_namespace,page_title), -- Special-purpose indexes INDEX (page_random), INDEX (page_len)) TYPE=InnoDB, DEFAULT CHARSET=utf8;---- Every edit of a page creates also a revision row.-- This stores metadata about the revision, and a reference-- to the text storage backend.--CREATE TABLE /*$wgDBprefix*/revision ( rev_id int(8) unsigned NOT NULL auto_increment, -- Key to page_id. This should _never_ be invalid. rev_page int(8) unsigned NOT NULL, -- Key to text.old_id, where the actual bulk text is stored. -- It's possible for multiple revisions to use the same text, -- for instance revisions where only metadata is altered -- or a rollback to a previous version. rev_text_id int(8) unsigned NOT NULL, -- Text comment summarizing the change. -- This text is shown in the history and other changes lists, -- rendered in a subset of wiki markup by Linker::formatComment() rev_comment tinyblob NOT NULL default '', -- Key to user.user_id of the user who made this edit. -- Stores 0 for anonymous edits and for some mass imports. rev_user int(5) unsigned NOT NULL default '0', -- Text username or IP address of the editor. rev_user_text varchar(255) binary NOT NULL default '', -- Timestamp rev_timestamp char(14) binary NOT NULL default '', -- Records whether the user marked the 'minor edit' checkbox. -- Many automated edits are marked as minor. rev_minor_edit tinyint(1) unsigned NOT NULL default '0', -- Not yet used; reserved for future changes to the deletion system. rev_deleted tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY rev_page_id (rev_page, rev_id), UNIQUE INDEX rev_id (rev_id), INDEX rev_timestamp (rev_timestamp), INDEX page_timestamp (rev_page,rev_timestamp), INDEX user_timestamp (rev_user,rev_timestamp), INDEX usertext_timestamp (rev_user_text,rev_timestamp)) TYPE=InnoDB, DEFAULT CHARSET=utf8;---- Holds text of individual page revisions.---- Field names are a holdover from the 'old' revisions table in-- MediaWiki 1.4 and earlier: an upgrade will transform that-- table into the 'text' table to minimize unnecessary churning-- and downtime. If upgrading, the other fields will be left unused.--CREATE TABLE /*$wgDBprefix*/text ( -- Unique text storage key number. -- Note that the 'oldid' parameter used in URLs does *not* -- refer to this number anymore, but to rev_id. -- -- revision.rev_text_id is a key to this column old_id int(8) unsigned NOT NULL auto_increment, -- Depending on the contents of the old_flags field, the text -- may be convenient plain text, or it may be funkily encoded. old_text mediumblob NOT NULL default '', -- Comma-separated list of flags: -- gzip: text is compressed with PHP's gzdeflate() function. -- utf8: text was stored as UTF-8. -- If $wgLegacyEncoding option is on, rows *without* this flag -- will be converted to UTF-8 transparently at load time. -- object: text field contained a serialized PHP object. -- The object either contains multiple versions compressed -- together to achieve a better compression ratio, or it refers -- to another row where the text can be found. old_flags tinyblob NOT NULL default '', PRIMARY KEY old_id (old_id)) TYPE=InnoDB, DEFAULT CHARSET=utf8;---- Holding area for deleted articles, which may be viewed-- or restored by admins through the Special:Undelete interface.-- The fields generally correspond to the page, revision, and text-- fields, with several caveats.--CREATE TABLE /*$wgDBprefix*/archive ( ar_namespace int NOT NULL default '0', ar_title varchar(255) binary NOT NULL default '', -- Newly deleted pages will not store text in this table, -- but will reference the separately existing text rows. -- This field is retained for backwards compatibility, -- so old archived pages will remain accessible after -- upgrading from 1.4 to 1.5. -- Text may be gzipped or otherwise funky. ar_text mediumblob NOT NULL default '', -- Basic revision stuff... ar_comment tinyblob NOT NULL default '', ar_user int(5) unsigned NOT NULL default '0', ar_user_text varchar(255) binary NOT NULL, ar_timestamp char(14) binary NOT NULL default '', ar_minor_edit tinyint(1) NOT NULL default '0',
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?