1 -- defines must comply with ^define\s*([^\s=]*)\s*=\s?'\{\$([^\}]*)\}';
2 define mw_prefix='{$wgDBprefix}';
5 CREATE SEQUENCE user_user_id_seq;
6 CREATE TABLE &mw_prefix.mwuser ( -- replace reserved word 'user'
7 user_id NUMBER NOT NULL,
8 user_name VARCHAR2(255) NOT NULL,
9 user_real_name VARCHAR2(512),
10 user_password VARCHAR2(255),
11 user_newpassword VARCHAR2(255),
12 user_newpass_time TIMESTAMP(6) WITH TIME ZONE,
13 user_token VARCHAR2(32),
14 user_email VARCHAR2(255),
15 user_email_token VARCHAR2(32),
16 user_email_token_expires TIMESTAMP(6) WITH TIME ZONE,
17 user_email_authenticated TIMESTAMP(6) WITH TIME ZONE,
19 user_touched TIMESTAMP(6) WITH TIME ZONE,
20 user_registration TIMESTAMP(6) WITH TIME ZONE,
21 user_editcount NUMBER,
22 user_password_expires TIMESTAMP(6) WITH TIME ZONE
24 ALTER TABLE &mw_prefix.mwuser ADD CONSTRAINT &mw_prefix.mwuser_pk PRIMARY KEY (user_id);
25 CREATE UNIQUE INDEX &mw_prefix.mwuser_u01 ON &mw_prefix.mwuser (user_name);
26 CREATE INDEX &mw_prefix.mwuser_i01 ON &mw_prefix.mwuser (user_email_token);
27 CREATE INDEX &mw_prefix.mwuser_i02 ON &mw_prefix.mwuser (user_email, user_name);
29 -- Create a dummy user to satisfy fk contraints especially with revisions
30 INSERT INTO &mw_prefix.mwuser
31 (user_id, user_name, user_options, user_touched, user_registration, user_editcount)
32 VALUES (0,'Anonymous','', current_timestamp, current_timestamp,0);
34 CREATE TABLE &mw_prefix.user_groups (
35 ug_user NUMBER DEFAULT 0 NOT NULL,
36 ug_group VARCHAR2(255) NOT NULL
38 ALTER TABLE &mw_prefix.user_groups ADD CONSTRAINT &mw_prefix.user_groups_fk1 FOREIGN KEY (ug_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
39 CREATE UNIQUE INDEX &mw_prefix.user_groups_u01 ON &mw_prefix.user_groups (ug_user,ug_group);
40 CREATE INDEX &mw_prefix.user_groups_i01 ON &mw_prefix.user_groups (ug_group);
42 CREATE TABLE &mw_prefix.user_former_groups (
43 ufg_user NUMBER DEFAULT 0 NOT NULL,
44 ufg_group VARCHAR2(255) NOT NULL
46 ALTER TABLE &mw_prefix.user_former_groups ADD CONSTRAINT &mw_prefix.user_former_groups_fk1 FOREIGN KEY (ufg_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
47 CREATE UNIQUE INDEX &mw_prefix.user_former_groups_u01 ON &mw_prefix.user_former_groups (ufg_user,ufg_group);
49 CREATE TABLE &mw_prefix.user_newtalk (
50 user_id NUMBER DEFAULT 0 NOT NULL,
51 user_ip VARCHAR2(40) NULL,
52 user_last_timestamp TIMESTAMP(6) WITH TIME ZONE
54 ALTER TABLE &mw_prefix.user_newtalk ADD CONSTRAINT &mw_prefix.user_newtalk_fk1 FOREIGN KEY (user_id) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
55 CREATE INDEX &mw_prefix.user_newtalk_i01 ON &mw_prefix.user_newtalk (user_id);
56 CREATE INDEX &mw_prefix.user_newtalk_i02 ON &mw_prefix.user_newtalk (user_ip);
58 CREATE TABLE &mw_prefix.user_properties (
59 up_user NUMBER NOT NULL,
60 up_property VARCHAR2(255) NOT NULL,
63 CREATE UNIQUE INDEX &mw_prefix.user_properties_u01 on &mw_prefix.user_properties (up_user,up_property);
64 CREATE INDEX &mw_prefix.user_properties_i01 on &mw_prefix.user_properties (up_property);
66 CREATE SEQUENCE page_page_id_seq;
67 CREATE TABLE &mw_prefix.page (
68 page_id NUMBER NOT NULL,
69 page_namespace NUMBER DEFAULT 0 NOT NULL,
70 page_title VARCHAR2(255) NOT NULL,
71 page_restrictions VARCHAR2(255),
72 page_counter NUMBER DEFAULT 0 NOT NULL,
73 page_is_redirect CHAR(1) DEFAULT '0' NOT NULL,
74 page_is_new CHAR(1) DEFAULT '0' NOT NULL,
75 page_random NUMBER(15,14) NOT NULL,
76 page_touched TIMESTAMP(6) WITH TIME ZONE,
77 page_links_updated TIMESTAMP(6) WITH TIME ZONE,
78 page_latest NUMBER DEFAULT 0 NOT NULL, -- FK?
79 page_len NUMBER DEFAULT 0 NOT NULL,
80 page_content_model VARCHAR2(32),
81 page_lang VARCHAR2(35) DEFAULT NULL
83 ALTER TABLE &mw_prefix.page ADD CONSTRAINT &mw_prefix.page_pk PRIMARY KEY (page_id);
84 CREATE UNIQUE INDEX &mw_prefix.page_u01 ON &mw_prefix.page (page_namespace,page_title);
85 CREATE INDEX &mw_prefix.page_i01 ON &mw_prefix.page (page_random);
86 CREATE INDEX &mw_prefix.page_i02 ON &mw_prefix.page (page_len);
87 CREATE INDEX &mw_prefix.page_i03 ON &mw_prefix.page (page_is_redirect, page_namespace, page_len);
89 -- Create a dummy page to satisfy fk contraints especially with revisions
90 INSERT INTO &mw_prefix.page
91 VALUES (0, 0, ' ', NULL, 0, 0, 0, 0, current_timestamp, NULL, 0, 0, NULL, NULL);
94 CREATE TRIGGER &mw_prefix.page_set_random BEFORE INSERT ON &mw_prefix.page
95 FOR EACH ROW WHEN (new.page_random IS NULL)
97 SELECT dbms_random.value INTO :NEW.page_random FROM dual;
101 CREATE SEQUENCE revision_rev_id_seq;
102 CREATE TABLE &mw_prefix.revision (
103 rev_id NUMBER NOT NULL,
104 rev_page NUMBER NOT NULL,
105 rev_text_id NUMBER NULL,
106 rev_comment VARCHAR2(255),
107 rev_user NUMBER DEFAULT 0 NOT NULL,
108 rev_user_text VARCHAR2(255) NOT NULL,
109 rev_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
110 rev_minor_edit CHAR(1) DEFAULT '0' NOT NULL,
111 rev_deleted CHAR(1) DEFAULT '0' NOT NULL,
113 rev_parent_id NUMBER DEFAULT NULL,
114 rev_sha1 VARCHAR2(32) NULL,
115 rev_content_model VARCHAR2(32),
116 rev_content_format VARCHAR2(64)
118 ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_pk PRIMARY KEY (rev_id);
119 ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_fk1 FOREIGN KEY (rev_page) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
120 ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_fk2 FOREIGN KEY (rev_user) REFERENCES &mw_prefix.mwuser(user_id) DEFERRABLE INITIALLY DEFERRED;
121 CREATE UNIQUE INDEX &mw_prefix.revision_u01 ON &mw_prefix.revision (rev_page, rev_id);
122 CREATE INDEX &mw_prefix.revision_i01 ON &mw_prefix.revision (rev_timestamp);
123 CREATE INDEX &mw_prefix.revision_i02 ON &mw_prefix.revision (rev_page,rev_timestamp);
124 CREATE INDEX &mw_prefix.revision_i03 ON &mw_prefix.revision (rev_user,rev_timestamp);
125 CREATE INDEX &mw_prefix.revision_i04 ON &mw_prefix.revision (rev_user_text,rev_timestamp);
126 CREATE INDEX &mw_prefix.revision_i05 ON &mw_prefix.revision (rev_page,rev_user,rev_timestamp);
128 CREATE SEQUENCE text_old_id_seq;
129 CREATE TABLE &mw_prefix.pagecontent ( -- replaces reserved word 'text'
130 old_id NUMBER NOT NULL,
132 old_flags VARCHAR2(255)
134 ALTER TABLE &mw_prefix.pagecontent ADD CONSTRAINT &mw_prefix.pagecontent_pk PRIMARY KEY (old_id);
136 CREATE SEQUENCE archive_ar_id_seq;
137 CREATE TABLE &mw_prefix.archive (
138 ar_id NUMBER NOT NULL,
139 ar_namespace NUMBER DEFAULT 0 NOT NULL,
140 ar_title VARCHAR2(255) NOT NULL,
142 ar_comment VARCHAR2(255),
143 ar_user NUMBER DEFAULT 0 NOT NULL,
144 ar_user_text VARCHAR2(255) NOT NULL,
145 ar_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
146 ar_minor_edit CHAR(1) DEFAULT '0' NOT NULL,
147 ar_flags VARCHAR2(255),
150 ar_deleted CHAR(1) DEFAULT '0' NOT NULL,
154 ar_sha1 VARCHAR2(32),
155 ar_content_model VARCHAR2(32),
156 ar_content_format VARCHAR2(64)
158 ALTER TABLE &mw_prefix.archive ADD CONSTRAINT &mw_prefix.archive_pk PRIMARY KEY (ar_id);
159 ALTER TABLE &mw_prefix.archive ADD CONSTRAINT &mw_prefix.archive_fk1 FOREIGN KEY (ar_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
160 CREATE INDEX &mw_prefix.archive_i01 ON &mw_prefix.archive (ar_namespace,ar_title,ar_timestamp);
161 CREATE INDEX &mw_prefix.archive_i02 ON &mw_prefix.archive (ar_user_text,ar_timestamp);
162 CREATE INDEX &mw_prefix.archive_i03 ON &mw_prefix.archive (ar_rev_id);
164 CREATE TABLE &mw_prefix.pagelinks (
165 pl_from NUMBER NOT NULL,
166 pl_namespace NUMBER DEFAULT 0 NOT NULL,
167 pl_title VARCHAR2(255) NOT NULL
169 ALTER TABLE &mw_prefix.pagelinks ADD CONSTRAINT &mw_prefix.pagelinks_fk1 FOREIGN KEY (pl_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
170 CREATE UNIQUE INDEX &mw_prefix.pagelinks_u01 ON &mw_prefix.pagelinks (pl_from,pl_namespace,pl_title);
171 CREATE UNIQUE INDEX &mw_prefix.pagelinks_u02 ON &mw_prefix.pagelinks (pl_namespace,pl_title,pl_from);
173 CREATE TABLE &mw_prefix.templatelinks (
174 tl_from NUMBER NOT NULL,
175 tl_namespace NUMBER DEFAULT 0 NOT NULL,
176 tl_title VARCHAR2(255) NOT NULL
178 ALTER TABLE &mw_prefix.templatelinks ADD CONSTRAINT &mw_prefix.templatelinks_fk1 FOREIGN KEY (tl_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
179 CREATE UNIQUE INDEX &mw_prefix.templatelinks_u01 ON &mw_prefix.templatelinks (tl_from,tl_namespace,tl_title);
180 CREATE UNIQUE INDEX &mw_prefix.templatelinks_u02 ON &mw_prefix.templatelinks (tl_namespace,tl_title,tl_from);
182 CREATE TABLE &mw_prefix.imagelinks (
183 il_from NUMBER NOT NULL,
184 il_to VARCHAR2(255) NOT NULL
186 ALTER TABLE &mw_prefix.imagelinks ADD CONSTRAINT &mw_prefix.imagelinks_fk1 FOREIGN KEY (il_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
187 CREATE UNIQUE INDEX &mw_prefix.imagelinks_u01 ON &mw_prefix.imagelinks (il_from,il_to);
188 CREATE UNIQUE INDEX &mw_prefix.imagelinks_u02 ON &mw_prefix.imagelinks (il_to,il_from);
191 CREATE TABLE &mw_prefix.categorylinks (
192 cl_from NUMBER NOT NULL,
193 cl_to VARCHAR2(255) NOT NULL,
194 cl_sortkey VARCHAR2(230),
195 cl_sortkey_prefix VARCHAR2(255),
196 cl_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
197 cl_collation VARCHAR2(32),
198 cl_type VARCHAR2(6) DEFAULT 'page' NOT NULL
200 ALTER TABLE &mw_prefix.categorylinks ADD CONSTRAINT &mw_prefix.categorylinks_fk1 FOREIGN KEY (cl_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
201 CREATE UNIQUE INDEX &mw_prefix.categorylinks_u01 ON &mw_prefix.categorylinks (cl_from,cl_to);
202 CREATE INDEX &mw_prefix.categorylinks_i01 ON &mw_prefix.categorylinks (cl_to,cl_type,cl_sortkey,cl_from);
203 CREATE INDEX &mw_prefix.categorylinks_i02 ON &mw_prefix.categorylinks (cl_to,cl_timestamp);
204 CREATE INDEX &mw_prefix.categorylinks_i03 ON &mw_prefix.categorylinks (cl_collation);
206 CREATE SEQUENCE category_cat_id_seq;
207 CREATE TABLE &mw_prefix.category (
208 cat_id NUMBER NOT NULL,
209 cat_title VARCHAR2(255) NOT NULL,
210 cat_pages NUMBER DEFAULT 0 NOT NULL,
211 cat_subcats NUMBER DEFAULT 0 NOT NULL,
212 cat_files NUMBER DEFAULT 0 NOT NULL
214 ALTER TABLE &mw_prefix.category ADD CONSTRAINT &mw_prefix.category_pk PRIMARY KEY (cat_id);
215 CREATE UNIQUE INDEX &mw_prefix.category_u01 ON &mw_prefix.category (cat_title);
216 CREATE INDEX &mw_prefix.category_i01 ON &mw_prefix.category (cat_pages);
218 CREATE SEQUENCE externallinks_el_id_seq;
219 CREATE TABLE &mw_prefix.externallinks (
220 el_id NUMBER NOT NULL,
221 el_from NUMBER NOT NULL,
222 el_to VARCHAR2(2048) NOT NULL,
223 el_index VARCHAR2(2048) NOT NULL
225 ALTER TABLE &mw_prefix.externallinks ADD CONSTRAINT &mw_prefix.externallinks_pk PRIMARY KEY (el_id);
226 ALTER TABLE &mw_prefix.externallinks ADD CONSTRAINT &mw_prefix.externallinks_fk1 FOREIGN KEY (el_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
227 CREATE INDEX &mw_prefix.externallinks_i01 ON &mw_prefix.externallinks (el_from, el_to);
228 CREATE INDEX &mw_prefix.externallinks_i02 ON &mw_prefix.externallinks (el_to, el_from);
229 CREATE INDEX &mw_prefix.externallinks_i03 ON &mw_prefix.externallinks (el_index);
231 CREATE TABLE &mw_prefix.langlinks (
232 ll_from NUMBER NOT NULL,
233 ll_lang VARCHAR2(20),
234 ll_title VARCHAR2(255)
236 ALTER TABLE &mw_prefix.langlinks ADD CONSTRAINT &mw_prefix.langlinks_fk1 FOREIGN KEY (ll_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
237 CREATE UNIQUE INDEX &mw_prefix.langlinks_u01 ON &mw_prefix.langlinks (ll_from, ll_lang);
238 CREATE INDEX &mw_prefix.langlinks_i01 ON &mw_prefix.langlinks (ll_lang, ll_title);
240 CREATE TABLE &mw_prefix.iwlinks (
241 iwl_from NUMBER DEFAULT 0 NOT NULL,
242 iwl_prefix VARCHAR2(20),
243 iwl_title VARCHAR2(255)
245 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui01 ON &mw_prefix.iwlinks (iwl_from, iwl_prefix, iwl_title);
246 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui02 ON &mw_prefix.iwlinks (iwl_prefix, iwl_title, iwl_from);
248 CREATE TABLE &mw_prefix.site_stats (
249 ss_row_id NUMBER NOT NULL ,
250 ss_total_views NUMBER DEFAULT 0,
251 ss_total_edits NUMBER DEFAULT 0,
252 ss_good_articles NUMBER DEFAULT 0,
253 ss_total_pages NUMBER DEFAULT -1,
254 ss_users NUMBER DEFAULT -1,
255 ss_active_users NUMBER DEFAULT -1,
256 ss_images NUMBER DEFAULT 0
258 CREATE UNIQUE INDEX &mw_prefix.site_stats_u01 ON &mw_prefix.site_stats (ss_row_id);
260 CREATE TABLE &mw_prefix.hitcounter (
261 hc_id NUMBER NOT NULL
264 CREATE SEQUENCE ipblocks_ipb_id_seq;
265 CREATE TABLE &mw_prefix.ipblocks (
266 ipb_id NUMBER NOT NULL,
267 ipb_address VARCHAR2(255) NULL,
268 ipb_user NUMBER DEFAULT 0 NOT NULL,
269 ipb_by NUMBER DEFAULT 0 NOT NULL,
270 ipb_by_text VARCHAR2(255) NULL,
271 ipb_reason VARCHAR2(255) NOT NULL,
272 ipb_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
273 ipb_auto CHAR(1) DEFAULT '0' NOT NULL,
274 ipb_anon_only CHAR(1) DEFAULT '0' NOT NULL,
275 ipb_create_account CHAR(1) DEFAULT '1' NOT NULL,
276 ipb_enable_autoblock CHAR(1) DEFAULT '1' NOT NULL,
277 ipb_expiry TIMESTAMP(6) WITH TIME ZONE NOT NULL,
278 ipb_range_start VARCHAR2(255),
279 ipb_range_end VARCHAR2(255),
280 ipb_deleted CHAR(1) DEFAULT '0' NOT NULL,
281 ipb_block_email CHAR(1) DEFAULT '0' NOT NULL,
282 ipb_allow_usertalk CHAR(1) DEFAULT '0' NOT NULL,
283 ipb_parent_block_id NUMBER DEFAULT NULL
285 ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_pk PRIMARY KEY (ipb_id);
286 ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_fk1 FOREIGN KEY (ipb_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
287 ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_fk2 FOREIGN KEY (ipb_by) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
288 CREATE UNIQUE INDEX &mw_prefix.ipblocks_u01 ON &mw_prefix.ipblocks (ipb_address, ipb_user, ipb_auto, ipb_anon_only);
289 CREATE INDEX &mw_prefix.ipblocks_i01 ON &mw_prefix.ipblocks (ipb_user);
290 CREATE INDEX &mw_prefix.ipblocks_i02 ON &mw_prefix.ipblocks (ipb_range_start, ipb_range_end);
291 CREATE INDEX &mw_prefix.ipblocks_i03 ON &mw_prefix.ipblocks (ipb_timestamp);
292 CREATE INDEX &mw_prefix.ipblocks_i04 ON &mw_prefix.ipblocks (ipb_expiry);
293 CREATE INDEX &mw_prefix.ipblocks_i05 ON &mw_prefix.ipblocks (ipb_parent_block_id);
295 CREATE TABLE &mw_prefix.image (
296 img_name VARCHAR2(255) NOT NULL,
297 img_size NUMBER DEFAULT 0 NOT NULL,
298 img_width NUMBER DEFAULT 0 NOT NULL,
299 img_height NUMBER DEFAULT 0 NOT NULL,
301 img_bits NUMBER DEFAULT 0 NOT NULL,
302 img_media_type VARCHAR2(32),
303 img_major_mime VARCHAR2(32) DEFAULT 'unknown',
304 img_minor_mime VARCHAR2(100) DEFAULT 'unknown',
305 img_description VARCHAR2(255),
306 img_user NUMBER DEFAULT 0 NOT NULL,
307 img_user_text VARCHAR2(255) NOT NULL,
308 img_timestamp TIMESTAMP(6) WITH TIME ZONE,
309 img_sha1 VARCHAR2(32)
311 ALTER TABLE &mw_prefix.image ADD CONSTRAINT &mw_prefix.image_pk PRIMARY KEY (img_name);
312 ALTER TABLE &mw_prefix.image ADD CONSTRAINT &mw_prefix.image_fk1 FOREIGN KEY (img_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
313 CREATE INDEX &mw_prefix.image_i01 ON &mw_prefix.image (img_user_text,img_timestamp);
314 CREATE INDEX &mw_prefix.image_i02 ON &mw_prefix.image (img_size);
315 CREATE INDEX &mw_prefix.image_i03 ON &mw_prefix.image (img_timestamp);
316 CREATE INDEX &mw_prefix.image_i04 ON &mw_prefix.image (img_sha1);
319 CREATE TABLE &mw_prefix.oldimage (
320 oi_name VARCHAR2(255) DEFAULT 0 NOT NULL,
321 oi_archive_name VARCHAR2(255),
322 oi_size NUMBER DEFAULT 0 NOT NULL,
323 oi_width NUMBER DEFAULT 0 NOT NULL,
324 oi_height NUMBER DEFAULT 0 NOT NULL,
325 oi_bits NUMBER DEFAULT 0 NOT NULL,
326 oi_description VARCHAR2(255),
327 oi_user NUMBER DEFAULT 0 NOT NULL,
328 oi_user_text VARCHAR2(255) NOT NULL,
329 oi_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
331 oi_media_type VARCHAR2(32) DEFAULT NULL,
332 oi_major_mime VARCHAR2(32) DEFAULT 'unknown',
333 oi_minor_mime VARCHAR2(100) DEFAULT 'unknown',
334 oi_deleted NUMBER DEFAULT 0 NOT NULL,
337 ALTER TABLE &mw_prefix.oldimage ADD CONSTRAINT &mw_prefix.oldimage_fk1 FOREIGN KEY (oi_name) REFERENCES &mw_prefix.image(img_name) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
338 ALTER TABLE &mw_prefix.oldimage ADD CONSTRAINT &mw_prefix.oldimage_fk2 FOREIGN KEY (oi_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
339 CREATE INDEX &mw_prefix.oldimage_i01 ON &mw_prefix.oldimage (oi_user_text,oi_timestamp);
340 CREATE INDEX &mw_prefix.oldimage_i02 ON &mw_prefix.oldimage (oi_name,oi_timestamp);
341 CREATE INDEX &mw_prefix.oldimage_i03 ON &mw_prefix.oldimage (oi_name,oi_archive_name);
342 CREATE INDEX &mw_prefix.oldimage_i04 ON &mw_prefix.oldimage (oi_sha1);
345 CREATE SEQUENCE filearchive_fa_id_seq;
346 CREATE TABLE &mw_prefix.filearchive (
347 fa_id NUMBER NOT NULL,
348 fa_name VARCHAR2(255) NOT NULL,
349 fa_archive_name VARCHAR2(255),
350 fa_storage_group VARCHAR2(16),
351 fa_storage_key VARCHAR2(64),
352 fa_deleted_user NUMBER DEFAULT 0 NOT NULL,
353 fa_deleted_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
354 fa_deleted_reason CLOB,
355 fa_size NUMBER DEFAULT 0 NOT NULL,
356 fa_width NUMBER DEFAULT 0 NOT NULL,
357 fa_height NUMBER DEFAULT 0 NOT NULL,
359 fa_bits NUMBER DEFAULT 0 NOT NULL,
360 fa_media_type VARCHAR2(32) DEFAULT NULL,
361 fa_major_mime VARCHAR2(32) DEFAULT 'unknown',
362 fa_minor_mime VARCHAR2(100) DEFAULT 'unknown',
363 fa_description VARCHAR2(255),
364 fa_user NUMBER DEFAULT 0 NOT NULL,
365 fa_user_text VARCHAR2(255) NOT NULL,
366 fa_timestamp TIMESTAMP(6) WITH TIME ZONE,
367 fa_deleted NUMBER DEFAULT 0 NOT NULL,
370 ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_pk PRIMARY KEY (fa_id);
371 ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_fk1 FOREIGN KEY (fa_deleted_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
372 ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_fk2 FOREIGN KEY (fa_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
373 CREATE INDEX &mw_prefix.filearchive_i01 ON &mw_prefix.filearchive (fa_name, fa_timestamp);
374 CREATE INDEX &mw_prefix.filearchive_i02 ON &mw_prefix.filearchive (fa_storage_group, fa_storage_key);
375 CREATE INDEX &mw_prefix.filearchive_i03 ON &mw_prefix.filearchive (fa_deleted_timestamp);
376 CREATE INDEX &mw_prefix.filearchive_i04 ON &mw_prefix.filearchive (fa_user_text,fa_timestamp);
377 CREATE INDEX &mw_prefix.filearchive_i05 ON &mw_prefix.filearchive (fa_sha1);
379 CREATE SEQUENCE uploadstash_us_id_seq;
380 CREATE TABLE &mw_prefix.uploadstash (
381 us_id NUMBER NOT NULL,
382 us_user NUMBER DEFAULT 0 NOT NULL,
383 us_key VARCHAR2(255) NOT NULL,
384 us_orig_path VARCHAR2(255) NOT NULL,
385 us_path VARCHAR2(255) NOT NULL,
386 us_source_type VARCHAR2(50),
387 us_timestamp TIMESTAMP(6) WITH TIME ZONE,
388 us_status VARCHAR2(50) NOT NULL,
390 us_size NUMBER NOT NULL,
391 us_sha1 VARCHAR2(32) NOT NULL,
392 us_mime VARCHAR2(255),
393 us_media_type VARCHAR2(32) DEFAULT NULL,
394 us_image_width NUMBER,
395 us_image_height NUMBER,
396 us_image_bits NUMBER,
399 ALTER TABLE &mw_prefix.uploadstash ADD CONSTRAINT &mw_prefix.uploadstash_pk PRIMARY KEY (us_id);
400 ALTER TABLE &mw_prefix.uploadstash ADD CONSTRAINT &mw_prefix.uploadstash_fk1 FOREIGN KEY (us_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
401 CREATE INDEX &mw_prefix.uploadstash_i01 ON &mw_prefix.uploadstash (us_user);
402 CREATE INDEX &mw_prefix.uploadstash_i02 ON &mw_prefix.uploadstash (us_timestamp);
403 CREATE UNIQUE INDEX &mw_prefix.uploadstash_u01 ON &mw_prefix.uploadstash (us_key);
405 CREATE SEQUENCE recentchanges_rc_id_seq;
406 CREATE TABLE &mw_prefix.recentchanges (
407 rc_id NUMBER NOT NULL,
408 rc_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
409 rc_cur_time TIMESTAMP(6) WITH TIME ZONE,
410 rc_user NUMBER DEFAULT 0 NOT NULL,
411 rc_user_text VARCHAR2(255) NOT NULL,
412 rc_namespace NUMBER DEFAULT 0 NOT NULL,
413 rc_title VARCHAR2(255) NOT NULL,
414 rc_comment VARCHAR2(255),
415 rc_minor CHAR(1) DEFAULT '0' NOT NULL,
416 rc_bot CHAR(1) DEFAULT '0' NOT NULL,
417 rc_new CHAR(1) DEFAULT '0' NOT NULL,
418 rc_cur_id NUMBER DEFAULT 0 NOT NULL,
419 rc_this_oldid NUMBER DEFAULT 0 NOT NULL,
420 rc_last_oldid NUMBER DEFAULT 0 NOT NULL,
421 rc_type CHAR(1) DEFAULT '0' NOT NULL,
422 rc_source VARCHAR2(16),
423 rc_patrolled CHAR(1) DEFAULT '0' NOT NULL,
427 rc_deleted CHAR(1) DEFAULT '0' NOT NULL,
428 rc_logid NUMBER DEFAULT 0 NOT NULL,
429 rc_log_type VARCHAR2(255),
430 rc_log_action VARCHAR2(255),
433 ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_pk PRIMARY KEY (rc_id);
434 ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk1 FOREIGN KEY (rc_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
435 ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk2 FOREIGN KEY (rc_cur_id) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
436 CREATE INDEX &mw_prefix.recentchanges_i01 ON &mw_prefix.recentchanges (rc_timestamp);
437 CREATE INDEX &mw_prefix.recentchanges_i02 ON &mw_prefix.recentchanges (rc_namespace, rc_title);
438 CREATE INDEX &mw_prefix.recentchanges_i03 ON &mw_prefix.recentchanges (rc_cur_id);
439 CREATE INDEX &mw_prefix.recentchanges_i04 ON &mw_prefix.recentchanges (rc_new,rc_namespace,rc_timestamp);
440 CREATE INDEX &mw_prefix.recentchanges_i05 ON &mw_prefix.recentchanges (rc_ip);
441 CREATE INDEX &mw_prefix.recentchanges_i06 ON &mw_prefix.recentchanges (rc_namespace, rc_user_text);
442 CREATE INDEX &mw_prefix.recentchanges_i07 ON &mw_prefix.recentchanges (rc_user_text, rc_timestamp);
444 CREATE TABLE &mw_prefix.watchlist (
445 wl_user NUMBER NOT NULL,
446 wl_namespace NUMBER DEFAULT 0 NOT NULL,
447 wl_title VARCHAR2(255) NOT NULL,
448 wl_notificationtimestamp TIMESTAMP(6) WITH TIME ZONE
450 ALTER TABLE &mw_prefix.watchlist ADD CONSTRAINT &mw_prefix.watchlist_fk1 FOREIGN KEY (wl_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
451 CREATE UNIQUE INDEX &mw_prefix.watchlist_u01 ON &mw_prefix.watchlist (wl_user, wl_namespace, wl_title);
452 CREATE INDEX &mw_prefix.watchlist_i01 ON &mw_prefix.watchlist (wl_namespace, wl_title);
455 CREATE TABLE &mw_prefix.searchindex (
456 si_page NUMBER NOT NULL,
457 si_title VARCHAR2(255),
458 si_text CLOB NOT NULL
460 CREATE UNIQUE INDEX &mw_prefix.searchindex_u01 ON &mw_prefix.searchindex (si_page);
462 CREATE TABLE &mw_prefix.interwiki (
463 iw_prefix VARCHAR2(32) NOT NULL,
464 iw_url VARCHAR2(127) NOT NULL,
465 iw_api BLOB NOT NULL,
466 iw_wikiid VARCHAR2(64),
467 iw_local CHAR(1) NOT NULL,
468 iw_trans CHAR(1) DEFAULT '0' NOT NULL
470 CREATE UNIQUE INDEX &mw_prefix.interwiki_u01 ON &mw_prefix.interwiki (iw_prefix);
472 CREATE TABLE &mw_prefix.querycache (
473 qc_type VARCHAR2(32) NOT NULL,
474 qc_value NUMBER DEFAULT 0 NOT NULL,
475 qc_namespace NUMBER DEFAULT 0 NOT NULL,
476 qc_title VARCHAR2(255) NOT NULL
478 CREATE INDEX &mw_prefix.querycache_u01 ON &mw_prefix.querycache (qc_type,qc_value);
480 CREATE TABLE &mw_prefix.objectcache (
481 keyname VARCHAR2(255) ,
483 exptime TIMESTAMP(6) WITH TIME ZONE NOT NULL
485 CREATE INDEX &mw_prefix.objectcache_i01 ON &mw_prefix.objectcache (exptime);
487 CREATE TABLE &mw_prefix.transcache (
488 tc_url VARCHAR2(255) NOT NULL,
489 tc_contents CLOB NOT NULL,
490 tc_time TIMESTAMP(6) WITH TIME ZONE NOT NULL
492 CREATE UNIQUE INDEX &mw_prefix.transcache_u01 ON &mw_prefix.transcache (tc_url);
495 CREATE SEQUENCE logging_log_id_seq;
496 CREATE TABLE &mw_prefix.logging (
497 log_id NUMBER NOT NULL,
498 log_type VARCHAR2(10) NOT NULL,
499 log_action VARCHAR2(10) NOT NULL,
500 log_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
501 log_user NUMBER DEFAULT 0 NOT NULL,
502 log_user_text VARCHAR2(255),
503 log_namespace NUMBER DEFAULT 0 NOT NULL,
504 log_title VARCHAR2(255) NOT NULL,
506 log_comment VARCHAR2(255),
508 log_deleted CHAR(1) DEFAULT '0' NOT NULL
510 ALTER TABLE &mw_prefix.logging ADD CONSTRAINT &mw_prefix.logging_pk PRIMARY KEY (log_id);
511 ALTER TABLE &mw_prefix.logging ADD CONSTRAINT &mw_prefix.logging_fk1 FOREIGN KEY (log_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
512 CREATE INDEX &mw_prefix.logging_i01 ON &mw_prefix.logging (log_type, log_timestamp);
513 CREATE INDEX &mw_prefix.logging_i02 ON &mw_prefix.logging (log_user, log_timestamp);
514 CREATE INDEX &mw_prefix.logging_i03 ON &mw_prefix.logging (log_namespace, log_title, log_timestamp);
515 CREATE INDEX &mw_prefix.logging_i04 ON &mw_prefix.logging (log_timestamp);
516 CREATE INDEX &mw_prefix.logging_i05 ON &mw_prefix.logging (log_type, log_action, log_timestamp);
517 CREATE INDEX &mw_prefix.logging_i06 ON &mw_prefix.logging (log_user_text, log_type, log_timestamp);
518 CREATE INDEX &mw_prefix.logging_i07 ON &mw_prefix.logging (log_user_text, log_timestamp);
520 CREATE TABLE &mw_prefix.log_search (
521 ls_field VARCHAR2(32) NOT NULL,
522 ls_value VARCHAR2(255) NOT NULL,
523 ls_log_id NuMBER DEFAULT 0 NOT NULL
525 ALTER TABLE &mw_prefix.log_search ADD CONSTRAINT log_search_pk PRIMARY KEY (ls_field,ls_value,ls_log_id);
526 CREATE INDEX &mw_prefix.log_search_i01 ON &mw_prefix.log_search (ls_log_id);
529 CREATE SEQUENCE job_job_id_seq;
530 CREATE TABLE &mw_prefix.job (
531 job_id NUMBER NOT NULL,
532 job_cmd VARCHAR2(60) NOT NULL,
533 job_namespace NUMBER DEFAULT 0 NOT NULL,
534 job_title VARCHAR2(255) NOT NULL,
535 job_timestamp TIMESTAMP(6) WITH TIME ZONE NULL,
536 job_params CLOB NOT NULL,
537 job_random NUMBER DEFAULT 0 NOT NULL,
538 job_token VARCHAR2(32),
539 job_token_timestamp TIMESTAMP(6) WITH TIME ZONE,
540 job_sha1 VARCHAR2(32),
541 job_attempts NUMBER DEFAULT 0 NOT NULL
543 ALTER TABLE &mw_prefix.job ADD CONSTRAINT &mw_prefix.job_pk PRIMARY KEY (job_id);
544 CREATE INDEX &mw_prefix.job_i01 ON &mw_prefix.job (job_cmd, job_namespace, job_title);
545 CREATE INDEX &mw_prefix.job_i02 ON &mw_prefix.job (job_timestamp);
546 CREATE INDEX &mw_prefix.job_i03 ON &mw_prefix.job (job_sha1);
547 CREATE INDEX &mw_prefix.job_i04 ON &mw_prefix.job (job_cmd,job_token,job_random);
548 CREATE INDEX &mw_prefix.job_i05 ON &mw_prefix.job (job_attempts);
550 CREATE TABLE &mw_prefix.querycache_info (
551 qci_type VARCHAR2(32) NOT NULL,
552 qci_timestamp TIMESTAMP(6) WITH TIME ZONE NULL
554 CREATE UNIQUE INDEX &mw_prefix.querycache_info_u01 ON &mw_prefix.querycache_info (qci_type);
556 CREATE TABLE &mw_prefix.redirect (
557 rd_from NUMBER NOT NULL,
558 rd_namespace NUMBER DEFAULT 0 NOT NULL,
559 rd_title VARCHAR2(255) NOT NULL,
560 rd_interwiki VARCHAR2(32),
561 rd_fragment VARCHAR2(255)
563 ALTER TABLE &mw_prefix.redirect ADD CONSTRAINT &mw_prefix.redirect_fk1 FOREIGN KEY (rd_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
564 CREATE INDEX &mw_prefix.redirect_i01 ON &mw_prefix.redirect (rd_namespace,rd_title,rd_from);
566 CREATE TABLE &mw_prefix.querycachetwo (
567 qcc_type VARCHAR2(32) NOT NULL,
568 qcc_value NUMBER DEFAULT 0 NOT NULL,
569 qcc_namespace NUMBER DEFAULT 0 NOT NULL,
570 qcc_title VARCHAR2(255),
571 qcc_namespacetwo NUMBER DEFAULT 0 NOT NULL,
572 qcc_titletwo VARCHAR2(255)
574 CREATE INDEX &mw_prefix.querycachetwo_i01 ON &mw_prefix.querycachetwo (qcc_type,qcc_value);
575 CREATE INDEX &mw_prefix.querycachetwo_i02 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespace,qcc_title);
576 CREATE INDEX &mw_prefix.querycachetwo_i03 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
578 CREATE SEQUENCE page_restrictions_pr_id_seq;
579 CREATE TABLE &mw_prefix.page_restrictions (
580 pr_id NUMBER NOT NULL,
581 pr_page NUMBER NOT NULL,
582 pr_type VARCHAR2(255) NOT NULL,
583 pr_level VARCHAR2(255) NOT NULL,
584 pr_cascade NUMBER NOT NULL,
586 pr_expiry TIMESTAMP(6) WITH TIME ZONE NULL
588 ALTER TABLE &mw_prefix.page_restrictions ADD CONSTRAINT &mw_prefix.page_restrictions_pk PRIMARY KEY (pr_id);
589 ALTER TABLE &mw_prefix.page_restrictions ADD CONSTRAINT &mw_prefix.page_restrictions_fk1 FOREIGN KEY (pr_page) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
590 CREATE UNIQUE INDEX &mw_prefix.page_restrictions_u01 ON &mw_prefix.page_restrictions (pr_page,pr_type);
591 CREATE INDEX &mw_prefix.page_restrictions_i01 ON &mw_prefix.page_restrictions (pr_type,pr_level);
592 CREATE INDEX &mw_prefix.page_restrictions_i02 ON &mw_prefix.page_restrictions (pr_level);
593 CREATE INDEX &mw_prefix.page_restrictions_i03 ON &mw_prefix.page_restrictions (pr_cascade);
595 CREATE TABLE &mw_prefix.protected_titles (
596 pt_namespace NUMBER DEFAULT 0 NOT NULL,
597 pt_title VARCHAR2(255) NOT NULL,
598 pt_user NUMBER NOT NULL,
599 pt_reason VARCHAR2(255),
600 pt_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
601 pt_expiry VARCHAR2(14) NOT NULL,
602 pt_create_perm VARCHAR2(60) NOT NULL
604 CREATE UNIQUE INDEX &mw_prefix.protected_titles_u01 ON &mw_prefix.protected_titles (pt_namespace,pt_title);
605 CREATE INDEX &mw_prefix.protected_titles_i01 ON &mw_prefix.protected_titles (pt_timestamp);
607 CREATE TABLE &mw_prefix.page_props (
608 pp_page NUMBER NOT NULL,
609 pp_propname VARCHAR2(60) NOT NULL,
610 pp_value BLOB NOT NULL
612 CREATE UNIQUE INDEX &mw_prefix.page_props_u01 ON &mw_prefix.page_props (pp_page,pp_propname);
615 CREATE TABLE &mw_prefix.updatelog (
616 ul_key VARCHAR2(255) NOT NULL,
619 ALTER TABLE &mw_prefix.updatelog ADD CONSTRAINT &mw_prefix.updatelog_pk PRIMARY KEY (ul_key);
621 CREATE TABLE &mw_prefix.change_tag (
622 ct_rc_id NUMBER NULL,
623 ct_log_id NUMBER NULL,
624 ct_rev_id NUMBER NULL,
625 ct_tag VARCHAR2(255) NOT NULL,
628 CREATE UNIQUE INDEX &mw_prefix.change_tag_u01 ON &mw_prefix.change_tag (ct_rc_id,ct_tag);
629 CREATE UNIQUE INDEX &mw_prefix.change_tag_u02 ON &mw_prefix.change_tag (ct_log_id,ct_tag);
630 CREATE UNIQUE INDEX &mw_prefix.change_tag_u03 ON &mw_prefix.change_tag (ct_rev_id,ct_tag);
631 CREATE INDEX &mw_prefix.change_tag_i01 ON &mw_prefix.change_tag (ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
633 CREATE TABLE &mw_prefix.tag_summary (
634 ts_rc_id NUMBER NULL,
635 ts_log_id NUMBER NULL,
636 ts_rev_id NUMBER NULL,
637 ts_tags BLOB NOT NULL
639 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u01 ON &mw_prefix.tag_summary (ts_rc_id);
640 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u02 ON &mw_prefix.tag_summary (ts_log_id);
641 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u03 ON &mw_prefix.tag_summary (ts_rev_id);
643 CREATE TABLE &mw_prefix.valid_tag (
644 vt_tag VARCHAR2(255) NOT NULL
646 ALTER TABLE &mw_prefix.valid_tag ADD CONSTRAINT &mw_prefix.valid_tag_pk PRIMARY KEY (vt_tag);
648 -- This table is not used unless profiling is turned on
649 --CREATE TABLE &mw_prefix.profiling (
650 -- pf_count NUMBER DEFAULT 0 NOT NULL,
651 -- pf_time NUMBER(18,10) DEFAULT 0 NOT NULL,
652 -- pf_memory NUMBER(18,10) DEFAULT 0 NOT NULL,
653 -- pf_name VARCHAR2(255),
654 -- pf_server VARCHAR2(30)
656 --CREATE UNIQUE INDEX &mw_prefix.profiling_u01 ON &mw_prefix.profiling (pf_name, pf_server);
658 CREATE INDEX &mw_prefix.si_title_idx ON &mw_prefix.searchindex(si_title) INDEXTYPE IS ctxsys.context;
659 CREATE INDEX &mw_prefix.si_text_idx ON &mw_prefix.searchindex(si_text) INDEXTYPE IS ctxsys.context;
661 CREATE TABLE &mw_prefix.l10n_cache (
662 lc_lang varchar2(32) NOT NULL,
663 lc_key varchar2(255) NOT NULL,
664 lc_value clob NOT NULL
666 CREATE INDEX &mw_prefix.l10n_cache_u01 ON &mw_prefix.l10n_cache (lc_lang, lc_key);
668 CREATE TABLE &mw_prefix.msg_resource (
669 mr_resource VARCHAR2(255) NOT NULL,
670 mr_lang varchar2(32) NOT NULL,
671 mr_blob BLOB NOT NULL,
672 mr_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL
674 CREATE UNIQUE INDEX &mw_prefix.msg_resource_u01 ON &mw_prefix.msg_resource (mr_resource, mr_lang);
676 CREATE TABLE &mw_prefix.msg_resource_links (
677 mrl_resource VARCHAR2(255) NOT NULL,
678 mrl_message VARCHAR2(255) NOT NULL
680 CREATE UNIQUE INDEX &mw_prefix.msg_resource_links_u01 ON &mw_prefix.msg_resource_links (mrl_message, mrl_resource);
682 CREATE TABLE &mw_prefix.module_deps (
683 md_module VARCHAR2(255) NOT NULL,
684 md_skin VARCHAR2(32) NOT NULL,
685 md_deps BLOB NOT NULL
687 CREATE UNIQUE INDEX &mw_prefix.module_deps_u01 ON &mw_prefix.module_deps (md_module, md_skin);
689 CREATE SEQUENCE sites_site_id_seq MINVALUE 0 START WITH 0;
690 CREATE TABLE &mw_prefix.sites (
691 site_id NUMBER NOT NULL,
692 site_global_key VARCHAR2(32) NOT NULL,
693 site_type VARCHAR2(32) NOT NULL,
694 site_group VARCHAR2(32) NOT NULL,
695 site_source VARCHAR2(32) NOT NULL,
696 site_language VARCHAR2(32) NOT NULL,
697 site_protocol VARCHAR2(32) NOT NULL,
698 site_domain VARCHAR2(255) NOT NULL,
699 site_data BLOB NOT NULL,
700 site_forward NUMBER(1) NOT NULL,
701 site_config BLOB NOT NULL
703 ALTER TABLE &mw_prefix.sites ADD CONSTRAINT &mw_prefix.sites_pk PRIMARY KEY (site_id);
704 CREATE UNIQUE INDEX &mw_prefix.sites_u01 ON &mw_prefix.sites (site_global_key);
705 CREATE INDEX &mw_prefix.sites_i01 ON &mw_prefix.sites (site_type);
706 CREATE INDEX &mw_prefix.sites_i02 ON &mw_prefix.sites (site_group);
707 CREATE INDEX &mw_prefix.sites_i03 ON &mw_prefix.sites (site_source);
708 CREATE INDEX &mw_prefix.sites_i04 ON &mw_prefix.sites (site_language);
709 CREATE INDEX &mw_prefix.sites_i05 ON &mw_prefix.sites (site_protocol);
710 CREATE INDEX &mw_prefix.sites_i06 ON &mw_prefix.sites (site_domain);
711 CREATE INDEX &mw_prefix.sites_i07 ON &mw_prefix.sites (site_forward);
713 CREATE TABLE &mw_prefix.site_identifiers (
714 si_site NUMBER NOT NULL,
715 si_type VARCHAR2(32) NOT NULL,
716 si_key VARCHAR2(32) NOT NULL
718 CREATE UNIQUE INDEX &mw_prefix.site_identifiers_u01 ON &mw_prefix.site_identifiers (si_type, si_key);
719 CREATE INDEX &mw_prefix.site_identifiers_i01 ON &mw_prefix.site_identifiers (si_site);
720 CREATE INDEX &mw_prefix.site_identifiers_i02 ON &mw_prefix.site_identifiers (si_key);
722 -- do not prefix this table as it breaks parserTests
723 CREATE TABLE wiki_field_info_full (
724 table_name VARCHAR2(35) NOT NULL,
725 column_name VARCHAR2(35) NOT NULL,
726 data_default VARCHAR2(4000),
727 data_length NUMBER NOT NULL,
728 data_type VARCHAR2(106),
729 not_null CHAR(1) NOT NULL,
734 ALTER TABLE wiki_field_info_full ADD CONSTRAINT wiki_field_info_full_pk PRIMARY KEY (table_name, column_name);
737 CREATE PROCEDURE fill_wiki_info IS
739 DELETE wiki_field_info_full;
741 FOR x_rec IN (SELECT t.table_name table_name, t.column_name,
742 t.data_default, t.data_length, t.data_type,
743 DECODE (t.nullable, 'Y', '1', 'N', '0') not_null,
745 FROM user_cons_columns ucc,
747 WHERE ucc.table_name = t.table_name
748 AND ucc.column_name = t.column_name
749 AND uc.constraint_name = ucc.constraint_name
750 AND uc.constraint_type = 'P'
751 AND ROWNUM < 2) prim,
753 FROM user_ind_columns uic,
755 WHERE uic.table_name = t.table_name
756 AND uic.column_name = t.column_name
757 AND ui.index_name = uic.index_name
758 AND ui.uniqueness = 'UNIQUE'
759 AND ROWNUM < 2) uniq,
761 FROM user_ind_columns uic,
763 WHERE uic.table_name = t.table_name
764 AND uic.column_name = t.column_name
765 AND ui.index_name = uic.index_name
766 AND ui.uniqueness = 'NONUNIQUE'
767 AND ROWNUM < 2) nonuniq
768 FROM user_tab_columns t, user_tables ut
769 WHERE ut.table_name = t.table_name)
771 INSERT INTO wiki_field_info_full
772 (table_name, column_name,
773 data_default, data_length,
774 data_type, not_null, prim,
777 VALUES (x_rec.table_name, x_rec.column_name,
778 x_rec.data_default, x_rec.data_length,
779 x_rec.data_type, x_rec.not_null, x_rec.prim,
780 x_rec.uniq, x_rec.nonuniq
788 CREATE OR REPLACE PROCEDURE duplicate_table(p_tabname IN VARCHAR2,
789 p_oldprefix IN VARCHAR2,
790 p_newprefix IN VARCHAR2,
791 p_temporary IN BOOLEAN) IS
792 e_table_not_exist EXCEPTION;
793 PRAGMA EXCEPTION_INIT(e_table_not_exist, -00942);
794 l_temp_ei_sql VARCHAR2(2000);
795 l_temporary BOOLEAN := p_temporary;
798 EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname ||
799 ' CASCADE CONSTRAINTS PURGE';
801 WHEN e_table_not_exist THEN
804 IF (p_tabname = 'SEARCHINDEX') THEN
805 l_temporary := FALSE;
807 IF (l_temporary) THEN
808 EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix ||
810 ' ON COMMIT PRESERVE ROWS AS SELECT * FROM ' ||
811 p_oldprefix || p_tabname || ' WHERE ROWNUM = 0';
813 EXECUTE IMMEDIATE 'CREATE TABLE ' || p_newprefix || p_tabname ||
814 ' AS SELECT * FROM ' || p_oldprefix || p_tabname ||
817 FOR rc IN (SELECT column_name, data_default
818 FROM user_tab_columns
819 WHERE table_name = p_oldprefix || p_tabname
820 AND data_default IS NOT NULL) LOOP
821 EXECUTE IMMEDIATE 'ALTER TABLE ' || p_newprefix || p_tabname ||
822 ' MODIFY ' || rc.column_name || ' DEFAULT ' ||
823 SUBSTR(rc.data_default, 1, 2000);
825 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('CONSTRAINT',
829 USER || '"."' || p_oldprefix,
830 USER || '"."' || p_newprefix),
831 '"' || constraint_name || '"',
832 '"' || p_newprefix || constraint_name || '"') DDLVC2,
834 FROM user_constraints uc
835 WHERE table_name = p_oldprefix || p_tabname
836 AND constraint_type = 'P') LOOP
837 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
838 l_temp_ei_sql := SUBSTR(l_temp_ei_sql,
842 INSTR(l_temp_ei_sql, 'PRIMARY KEY') + 1) + 1);
843 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
844 EXECUTE IMMEDIATE l_temp_ei_sql;
847 IF (NOT l_temporary) THEN
848 FOR rc IN (SELECT REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('REF_CONSTRAINT',
852 USER || '"."' || p_oldprefix,
853 USER || '"."' || p_newprefix) DDLVC2,
855 FROM user_constraints uc
856 WHERE table_name = p_oldprefix || p_tabname
857 AND constraint_type = 'R') LOOP
858 IF nvl(length(l_temp_ei_sql), 0) > 0 AND
859 INSTR(l_temp_ei_sql, 'PRIMARY KEY') = 0 THEN
860 EXECUTE IMMEDIATE l_temp_ei_sql;
864 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
868 USER || '"."' || p_oldprefix,
869 USER || '"."' || p_newprefix),
870 '"' || index_name || '"',
871 '"' || p_newprefix || index_name || '"') DDLVC2,
875 WHERE table_name = p_oldprefix || p_tabname
876 AND index_type NOT IN ('LOB', 'DOMAIN')
879 FROM user_constraints
880 WHERE table_name = ui.table_name
881 AND constraint_name = ui.index_name)) LOOP
882 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
883 l_temp_ei_sql := SUBSTR(l_temp_ei_sql,
888 '"' || USER || '"."' || p_newprefix || '"') + 1) + 1);
889 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
890 EXECUTE IMMEDIATE l_temp_ei_sql;
893 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
897 USER || '"."' || p_oldprefix,
898 USER || '"."' || p_newprefix),
899 '"' || index_name || '"',
900 '"' || p_newprefix || index_name || '"') DDLVC2,
904 WHERE table_name = p_oldprefix || p_tabname
905 AND index_type = 'DOMAIN'
908 FROM user_constraints
909 WHERE table_name = ui.table_name
910 AND constraint_name = ui.index_name)) LOOP
911 l_temp_ei_sql := rc.ddlvc2;
912 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
913 EXECUTE IMMEDIATE l_temp_ei_sql;
916 FOR rc IN (SELECT REPLACE(REPLACE(UPPER(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('TRIGGER',
920 USER || '"."' || p_oldprefix,
921 USER || '"."' || p_newprefix),
922 ' ON ' || p_oldprefix || p_tabname,
923 ' ON ' || p_newprefix || p_tabname) DDLVC2,
926 WHERE table_name = p_oldprefix || p_tabname) LOOP
927 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'ALTER ') - 1);
928 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
929 EXECUTE IMMEDIATE l_temp_ei_sql;
937 CREATE OR REPLACE FUNCTION BITOR (x IN NUMBER, y IN NUMBER) RETURN NUMBER AS
939 RETURN (x + y - BITAND(x, y));
944 CREATE OR REPLACE FUNCTION BITNOT (x IN NUMBER) RETURN NUMBER AS
946 RETURN (4294967295 - x);
950 CREATE OR REPLACE TYPE GET_OUTPUT_TYPE IS TABLE OF VARCHAR2(255);
953 CREATE OR REPLACE FUNCTION GET_OUTPUT_LINES RETURN GET_OUTPUT_TYPE PIPELINED AS
954 v_line VARCHAR2(255);
955 v_status INTEGER := 0;
959 DBMS_OUTPUT.GET_LINE(v_line, v_status);
960 IF (v_status = 0) THEN RETURN; END IF;
971 CREATE OR REPLACE FUNCTION GET_SEQUENCE_VALUE(seq IN VARCHAR2) RETURN NUMBER AS
974 EXECUTE IMMEDIATE 'SELECT '||seq||'.NEXTVAL INTO :outVar FROM DUAL' INTO v_value;