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.
5 -- Indexes should be defined here; please import the rest from indexes.sql.
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
)
20 CREATE TABLE user_newtalk (
21 user_id
int(5) NOT NULL default '0',
22 user_ip
varchar(40) NOT NULL default ''
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
)
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
)
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 ''
73 -- Track links that do exist
74 -- l_from and l_to key to cur_id
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
),
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
),
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
),
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
)
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 UNIQUE KEY img_name (img_name
)
167 CREATE TABLE oldimage (
168 oi_name
varchar(255) binary NOT NULL default '',
169 oi_archive_name
varchar(255) binary NOT NULL default '',
170 oi_size
int(8) unsigned
NOT NULL default 0,
171 oi_description tinyblob
NOT NULL default '',
172 oi_user
int(5) unsigned
NOT NULL default '0',
173 oi_user_text
varchar(255) binary NOT NULL default '',
174 oi_timestamp
char(14) binary NOT NULL default ''
177 CREATE TABLE recentchanges (
178 rc_timestamp
varchar(14) binary NOT NULL default '',
179 rc_cur_time
varchar(14) binary NOT NULL default '',
180 rc_user
int(10) unsigned
NOT NULL default '0',
181 rc_user_text
varchar(255) binary NOT NULL default '',
182 rc_namespace
tinyint(3) unsigned
NOT NULL default '0',
183 rc_title
varchar(255) binary NOT NULL default '',
184 rc_comment
varchar(255) binary NOT NULL default '',
185 rc_minor
tinyint(3) unsigned
NOT NULL default '0',
186 rc_bot
tinyint(3) unsigned
NOT NULL default '0',
187 rc_new
tinyint(3) unsigned
NOT NULL default '0',
188 rc_cur_id
int(10) unsigned
NOT NULL default '0',
189 rc_this_oldid
int(10) unsigned
NOT NULL default '0',
190 rc_last_oldid
int(10) unsigned
NOT NULL default '0',
191 rc_type
tinyint(3) unsigned
NOT NULL default '0',
192 rc_moved_to_ns
tinyint(3) unsigned
NOT NULL default '0',
193 rc_moved_to_title
varchar(255) binary NOT NULL default '',
194 rc_ip
char(15) NOT NULL default ''
197 CREATE TABLE watchlist (
198 wl_user
int(5) unsigned
NOT NULL,
199 wl_namespace
tinyint(2) unsigned
NOT NULL default '0',
200 wl_title
varchar(255) binary NOT NULL default '',
201 UNIQUE KEY (wl_user
, wl_namespace
, wl_title
)
205 math_inputhash
varchar(16) NOT NULL,
206 math_outputhash
varchar(16) NOT NULL,
207 math_html_conservativeness
tinyint(1) NOT NULL,
210 UNIQUE KEY math_inputhash (math_inputhash
)
214 -- Table searchindex must be MyISAM for fulltext support
216 CREATE TABLE searchindex (
217 si_page
int(8) unsigned
NOT NULL,
218 si_title
varchar(255) NOT NULL default '',
219 si_text mediumtext
NOT NULL default '',
221 ) TYPE=MyISAM PACK_KEYS
=1;
223 CREATE TABLE interwiki (
224 iw_prefix
char(32) NOT NULL,
225 iw_url
char(127) NOT NULL,
226 iw_local BOOL
NOT NULL,
227 UNIQUE KEY iw_prefix (iw_prefix
)
230 -- Used for caching expensive grouped queries
231 CREATE TABLE querycache (
232 qc_type
char(32) NOT NULL,
233 qc_value
int(5) unsigned
NOT NULL default '0',
234 qc_namespace
tinyint(2) unsigned
NOT NULL default '0',
235 qc_title
char(255) binary NOT NULL default '',
236 KEY (qc_type
,qc_value
)
239 -- For a few generic cache operations if not using Memcached
240 CREATE TABLE objectcache (
241 keyname
char(255) binary not null default '',
244 unique key (keyname
),
248 -- For storing revision text
250 blob_index
char(255) binary NOT NULL default '',
251 blob_data longblob
NOT NULL default '',
252 UNIQUE key blob_index (blob_index
)