newbie detector
[mediawiki.git] / maintenance / tables.sql
blobda269c6bb990bb6fd199a7df6c9b64f64ce48894
1 -- SQL to create the initial tables for the Wikipedia database.
2 -- This is read and executed by the install script; you should
3 -- never have to run it by itself.
4 --
5 -- Indexes should be defined here; please import the rest from indexes.sql.
7 CREATE TABLE user (
8   user_id int(5) unsigned NOT NULL auto_increment,
9   user_name varchar(255) binary NOT NULL default '',
10   user_real_name varchar(255) binary NOT NULL default '',
11   user_rights tinyblob NOT NULL default '',
12   user_password tinyblob NOT NULL default '',
13   user_newpassword tinyblob NOT NULL default '',
14   user_email tinytext NOT NULL default '',
15   user_options blob NOT NULL default '',  
16   user_touched char(14) binary NOT NULL default '',
17   UNIQUE KEY user_id (user_id)
18 ) PACK_KEYS=1;
19         
20 CREATE TABLE user_newtalk (
21   user_id int(5) NOT NULL default '0',
22   user_ip varchar(40) NOT NULL default ''
25 CREATE TABLE cur (
26   cur_id int(8) unsigned NOT NULL auto_increment,
27   cur_namespace tinyint(2) unsigned NOT NULL default '0',
28   cur_title varchar(255) binary NOT NULL default '',
29   cur_text mediumtext NOT NULL default '',
30   cur_comment tinyblob NOT NULL default '',
31   cur_user int(5) unsigned NOT NULL default '0',
32   cur_user_text varchar(255) binary NOT NULL default '',
33   cur_timestamp char(14) binary NOT NULL default '',
34   cur_restrictions tinyblob NOT NULL default '',
35   cur_counter bigint(20) unsigned NOT NULL default '0',
36   cur_is_redirect tinyint(1) unsigned NOT NULL default '0',
37   cur_minor_edit tinyint(1) unsigned NOT NULL default '0',
38   cur_is_new tinyint(1) unsigned NOT NULL default '0',
39   cur_random real unsigned NOT NULL,
40   cur_touched char(14) binary NOT NULL default '',
41   inverse_timestamp char(14) binary NOT NULL default '',
42   UNIQUE KEY cur_id (cur_id)
43 ) PACK_KEYS=1;
45 CREATE TABLE old (
46   old_id int(8) unsigned NOT NULL auto_increment,
47   old_namespace tinyint(2) unsigned NOT NULL default '0',
48   old_title varchar(255) binary NOT NULL default '',
49   old_text mediumtext NOT NULL default '',
50   old_comment tinyblob NOT NULL default '',
51   old_user int(5) unsigned NOT NULL default '0',
52   old_user_text varchar(255) binary NOT NULL,
53   old_timestamp char(14) binary NOT NULL default '',
54   old_minor_edit tinyint(1) NOT NULL default '0',
55   old_flags tinyblob NOT NULL default '',
56   inverse_timestamp char(14) binary NOT NULL default '',
57   UNIQUE KEY old_id (old_id)
58 ) PACK_KEYS=1;
60 CREATE TABLE archive (
61   ar_namespace tinyint(2) unsigned NOT NULL default '0',
62   ar_title varchar(255) binary NOT NULL default '',
63   ar_text mediumtext NOT NULL default '',
64   ar_comment tinyblob NOT NULL default '',
65   ar_user int(5) unsigned NOT NULL default '0',
66   ar_user_text varchar(255) binary NOT NULL,
67   ar_timestamp char(14) binary NOT NULL default '',
68   ar_minor_edit tinyint(1) NOT NULL default '0',
69   ar_flags tinyblob NOT NULL default ''
70 ) PACK_KEYS=1;
73 -- Track links that do exist
74 -- l_from and l_to key to cur_id
76 CREATE TABLE links (
77   l_from int(8) unsigned NOT NULL default '0',
78   l_to int(8) unsigned NOT NULL default '0',
79   UNIQUE KEY l_from(l_from,l_to),
80   KEY (l_to)
84 -- Track links to pages that don't yet exist.
85 -- bl_from keys to cur_id
86 -- bl_to is a text link (namespace:title)
88 CREATE TABLE brokenlinks (
89   bl_from int(8) unsigned NOT NULL default '0',
90   bl_to varchar(255) binary NOT NULL default '',
91   UNIQUE KEY bl_from(bl_from,bl_to),
92   KEY (bl_to)
96 -- Track links to images *used inline*
97 -- il_from keys to cur_id, il_to keys to image_name.
98 -- We don't distinguish live from broken links.
100 CREATE TABLE imagelinks (
101   il_from int(8) unsigned NOT NULL default '0',
102   il_to varchar(255) binary NOT NULL default '',
103   UNIQUE KEY il_from(il_from,il_to),
104   KEY (il_to)
108 -- Track category inclusions *used inline*
109 -- cl_from keys to cur_id, cl_to keys to cur_title of the category page.
110 -- cl_sortkey is the title of the linking page or an optional override
111 -- cl_timestamp marks when the link was last added
113 CREATE TABLE categorylinks (
114   cl_from int(8) unsigned NOT NULL default '0',
115   cl_to varchar(255) binary NOT NULL default '',
116   cl_sortkey varchar(255) binary NOT NULL default '',
117   cl_timestamp timestamp NOT NULL,
118   UNIQUE KEY cl_from(cl_from,cl_to),
119   KEY cl_sortkey(cl_to,cl_sortkey(128)),
120   KEY cl_timestamp(cl_to,cl_timestamp)
124 -- Stores (possibly gzipped) serialized objects with
125 -- cache arrays to reduce database load slurping up
126 -- from links and brokenlinks.
128 CREATE TABLE linkscc (
129   lcc_pageid INT UNSIGNED NOT NULL UNIQUE KEY,
130   lcc_cacheobj MEDIUMBLOB NOT NULL
133 CREATE TABLE site_stats (
134   ss_row_id int(8) unsigned NOT NULL,
135   ss_total_views bigint(20) unsigned default '0',
136   ss_total_edits bigint(20) unsigned default '0',
137   ss_good_articles bigint(20) unsigned default '0',
138   UNIQUE KEY ss_row_id (ss_row_id)
141 CREATE TABLE hitcounter (
142   hc_id INTEGER UNSIGNED NOT NULL
143 ) TYPE=HEAP MAX_ROWS=25000;
145 CREATE TABLE ipblocks (
146   ipb_id int(8) NOT NULL auto_increment,
147   ipb_address varchar(40) binary NOT NULL default '',
148   ipb_user int(8) unsigned NOT NULL default '0',
149   ipb_by int(8) unsigned NOT NULL default '0',
150   ipb_reason tinyblob NOT NULL default '',
151   ipb_timestamp char(14) binary NOT NULL default '',
152   ipb_auto tinyint(1) NOT NULL default '0',
153   ipb_expiry char(14) binary NOT NULL default '',
154   UNIQUE KEY ipb_id (ipb_id)
155 ) PACK_KEYS=1;
157 CREATE TABLE image (
158   img_name varchar(255) binary NOT NULL default '',
159   img_size int(8) unsigned NOT NULL default '0',
160   img_description tinyblob NOT NULL default '',
161   img_user int(5) unsigned NOT NULL default '0',
162   img_user_text varchar(255) binary NOT NULL default '',
163   img_timestamp char(14) binary NOT NULL default ''
164 ) PACK_KEYS=1;
166 CREATE TABLE oldimage (
167   oi_name varchar(255) binary NOT NULL default '',
168   oi_archive_name varchar(255) binary NOT NULL default '',
169   oi_size int(8) unsigned NOT NULL default 0,
170   oi_description tinyblob NOT NULL default '',
171   oi_user int(5) unsigned NOT NULL default '0',
172   oi_user_text varchar(255) binary NOT NULL default '',
173   oi_timestamp char(14) binary NOT NULL default ''
174 ) PACK_KEYS=1;
176 CREATE TABLE recentchanges (
177   rc_timestamp varchar(14) binary NOT NULL default '',
178   rc_cur_time varchar(14) binary NOT NULL default '',
179   rc_user int(10) unsigned NOT NULL default '0',
180   rc_user_text varchar(255) binary NOT NULL default '',
181   rc_namespace tinyint(3) unsigned NOT NULL default '0',
182   rc_title varchar(255) binary NOT NULL default '',
183   rc_comment varchar(255) binary NOT NULL default '',
184   rc_minor tinyint(3) unsigned NOT NULL default '0',
185   rc_bot tinyint(3) unsigned NOT NULL default '0',
186   rc_new tinyint(3) unsigned NOT NULL default '0',
187   rc_cur_id int(10) unsigned NOT NULL default '0',
188   rc_this_oldid int(10) unsigned NOT NULL default '0',
189   rc_last_oldid int(10) unsigned NOT NULL default '0',
190   rc_type tinyint(3) unsigned NOT NULL default '0',
191   rc_moved_to_ns tinyint(3) unsigned NOT NULL default '0',
192   rc_moved_to_title varchar(255) binary NOT NULL default '',
193   rc_ip char(15) NOT NULL default ''
194 ) PACK_KEYS=1;
196 CREATE TABLE watchlist (
197   wl_user int(5) unsigned NOT NULL,
198   wl_namespace tinyint(2) unsigned NOT NULL default '0',
199   wl_title varchar(255) binary NOT NULL default '',
200   UNIQUE KEY (wl_user, wl_namespace, wl_title)
201 ) PACK_KEYS=1;
203 CREATE TABLE math (
204   math_inputhash varchar(16) NOT NULL,
205   math_outputhash varchar(16) NOT NULL,
206   math_html_conservativeness tinyint(1) NOT NULL,
207   math_html text,
208   math_mathml text,
209   UNIQUE KEY math_inputhash (math_inputhash)
213 -- Table searchindex must be MyISAM for fulltext support
215 CREATE TABLE searchindex (
216   si_page int(8) unsigned NOT NULL,
217   si_title varchar(255) NOT NULL default '',
218   si_text mediumtext NOT NULL default '',
219   UNIQUE KEY (si_page)
220 ) TYPE=MyISAM PACK_KEYS=1;
222 CREATE TABLE interwiki (
223   iw_prefix char(32) NOT NULL,
224   iw_url char(127) NOT NULL,
225   iw_local BOOL NOT NULL,
226   UNIQUE KEY iw_prefix (iw_prefix)
229 -- Used for caching expensive grouped queries
230 CREATE TABLE querycache (
231   qc_type char(32) NOT NULL,
232   qc_value int(5) unsigned NOT NULL default '0',
233   qc_namespace tinyint(2) unsigned NOT NULL default '0',
234   qc_title char(255) binary NOT NULL default '',
235   KEY (qc_type,qc_value)
238 -- For a few generic cache operations if not using Memcached
239 CREATE TABLE objectcache (
240   keyname char(255) binary not null default '',
241   value mediumblob,
242   exptime datetime,
243   unique key (keyname),
244   key (exptime)
247 -- For storing revision text
248 CREATE TABLE blobs (
249   blob_index char(255) binary NOT NULL default '',
250   blob_data longblob NOT NULL default '',
251   UNIQUE key blob_index (blob_index)