1 -- defines must comply with ^define\s*([^\s=]*)\s*=\s?'\{\$([^\}]*)\}';
2 define mw_prefix='{$wgDBprefix}';
5 CREATE SEQUENCE user_user_id_seq MINVALUE 0 START WITH 0;
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,
23 ALTER TABLE &mw_prefix.mwuser ADD CONSTRAINT &mw_prefix.mwuser_pk PRIMARY KEY (user_id);
24 CREATE UNIQUE INDEX &mw_prefix.mwuser_u01 ON &mw_prefix.mwuser (user_name);
25 CREATE INDEX &mw_prefix.mwuser_i01 ON &mw_prefix.mwuser (user_email_token);
26 CREATE INDEX &mw_prefix.mwuser_i02 ON &mw_prefix.mwuser (user_email, user_name);
28 -- Create a dummy user to satisfy fk contraints especially with revisions
29 INSERT INTO &mw_prefix.mwuser
30 VALUES (user_user_id_seq.nextval,'Anonymous',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, '', current_timestamp, current_timestamp, 0);
32 CREATE TABLE &mw_prefix.user_groups (
33 ug_user NUMBER DEFAULT 0 NOT NULL,
34 ug_group VARCHAR2(255) NOT NULL
36 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;
37 CREATE UNIQUE INDEX &mw_prefix.user_groups_u01 ON &mw_prefix.user_groups (ug_user,ug_group);
38 CREATE INDEX &mw_prefix.user_groups_i01 ON &mw_prefix.user_groups (ug_group);
40 CREATE TABLE &mw_prefix.user_former_groups (
41 ufg_user NUMBER DEFAULT 0 NOT NULL,
42 ufg_group VARCHAR2(255) NOT NULL
44 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;
45 CREATE UNIQUE INDEX &mw_prefix.user_former_groups_u01 ON &mw_prefix.user_former_groups (ufg_user,ufg_group);
47 CREATE TABLE &mw_prefix.user_newtalk (
48 user_id NUMBER DEFAULT 0 NOT NULL,
49 user_ip VARCHAR2(40) NULL,
50 user_last_timestamp TIMESTAMP(6) WITH TIME ZONE
52 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;
53 CREATE INDEX &mw_prefix.user_newtalk_i01 ON &mw_prefix.user_newtalk (user_id);
54 CREATE INDEX &mw_prefix.user_newtalk_i02 ON &mw_prefix.user_newtalk (user_ip);
56 CREATE TABLE &mw_prefix.user_properties (
57 up_user NUMBER NOT NULL,
58 up_property VARCHAR2(255) NOT NULL,
61 CREATE UNIQUE INDEX &mw_prefix.user_properties_u01 on &mw_prefix.user_properties (up_user,up_property);
62 CREATE INDEX &mw_prefix.user_properties_i01 on &mw_prefix.user_properties (up_property);
64 CREATE SEQUENCE page_page_id_seq;
65 CREATE TABLE &mw_prefix.page (
66 page_id NUMBER NOT NULL,
67 page_namespace NUMBER DEFAULT 0 NOT NULL,
68 page_title VARCHAR2(255) NOT NULL,
69 page_restrictions VARCHAR2(255),
70 page_counter NUMBER DEFAULT 0 NOT NULL,
71 page_is_redirect CHAR(1) DEFAULT '0' NOT NULL,
72 page_is_new CHAR(1) DEFAULT '0' NOT NULL,
73 page_random NUMBER(15,14) NOT NULL,
74 page_touched TIMESTAMP(6) WITH TIME ZONE,
75 page_latest NUMBER DEFAULT 0 NOT NULL, -- FK?
76 page_len NUMBER DEFAULT 0 NOT NULL,
77 page_content_model VARCHAR2(32)
79 ALTER TABLE &mw_prefix.page ADD CONSTRAINT &mw_prefix.page_pk PRIMARY KEY (page_id);
80 CREATE UNIQUE INDEX &mw_prefix.page_u01 ON &mw_prefix.page (page_namespace,page_title);
81 CREATE INDEX &mw_prefix.page_i01 ON &mw_prefix.page (page_random);
82 CREATE INDEX &mw_prefix.page_i02 ON &mw_prefix.page (page_len);
83 CREATE INDEX &mw_prefix.page_i03 ON &mw_prefix.page (page_is_redirect, page_namespace, page_len);
85 -- Create a dummy page to satisfy fk contraints especially with revisions
86 INSERT INTO &mw_prefix.page
87 VALUES (0, 0, ' ', NULL, 0, 0, 0, 0, current_timestamp, 0, 0, NULL);
90 CREATE TRIGGER &mw_prefix.page_set_random BEFORE INSERT ON &mw_prefix.page
91 FOR EACH ROW WHEN (new.page_random IS NULL)
93 SELECT dbms_random.value INTO :NEW.page_random FROM dual;
97 CREATE SEQUENCE revision_rev_id_seq;
98 CREATE TABLE &mw_prefix.revision (
99 rev_id NUMBER NOT NULL,
100 rev_page NUMBER NOT NULL,
101 rev_text_id NUMBER NULL,
102 rev_comment VARCHAR2(255),
103 rev_user NUMBER DEFAULT 0 NOT NULL,
104 rev_user_text VARCHAR2(255) NOT NULL,
105 rev_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
106 rev_minor_edit CHAR(1) DEFAULT '0' NOT NULL,
107 rev_deleted CHAR(1) DEFAULT '0' NOT NULL,
109 rev_parent_id NUMBER DEFAULT NULL,
110 rev_sha1 VARCHAR2(32) NULL,
111 rev_content_model VARCHAR2(32),
112 rev_content_format VARCHAR2(64)
114 ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_pk PRIMARY KEY (rev_id);
115 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;
116 ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_fk2 FOREIGN KEY (rev_user) REFERENCES &mw_prefix.mwuser(user_id) DEFERRABLE INITIALLY DEFERRED;
117 CREATE UNIQUE INDEX &mw_prefix.revision_u01 ON &mw_prefix.revision (rev_page, rev_id);
118 CREATE INDEX &mw_prefix.revision_i01 ON &mw_prefix.revision (rev_timestamp);
119 CREATE INDEX &mw_prefix.revision_i02 ON &mw_prefix.revision (rev_page,rev_timestamp);
120 CREATE INDEX &mw_prefix.revision_i03 ON &mw_prefix.revision (rev_user,rev_timestamp);
121 CREATE INDEX &mw_prefix.revision_i04 ON &mw_prefix.revision (rev_user_text,rev_timestamp);
122 CREATE INDEX &mw_prefix.revision_i05 ON &mw_prefix.revision (rev_page,rev_user,rev_timestamp);
124 CREATE SEQUENCE text_old_id_seq;
125 CREATE TABLE &mw_prefix.pagecontent ( -- replaces reserved word 'text'
126 old_id NUMBER NOT NULL,
128 old_flags VARCHAR2(255)
130 ALTER TABLE &mw_prefix.pagecontent ADD CONSTRAINT &mw_prefix.pagecontent_pk PRIMARY KEY (old_id);
132 CREATE TABLE &mw_prefix.archive (
133 ar_namespace NUMBER DEFAULT 0 NOT NULL,
134 ar_title VARCHAR2(255) NOT NULL,
136 ar_comment VARCHAR2(255),
137 ar_user NUMBER DEFAULT 0 NOT NULL,
138 ar_user_text VARCHAR2(255) NOT NULL,
139 ar_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
140 ar_minor_edit CHAR(1) DEFAULT '0' NOT NULL,
141 ar_flags VARCHAR2(255),
144 ar_deleted CHAR(1) DEFAULT '0' NOT NULL,
148 ar_sha1 VARCHAR2(32),
149 ar_content_model VARCHAR2(32),
150 ar_content_format VARCHAR2(64)
152 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;
153 CREATE INDEX &mw_prefix.archive_i01 ON &mw_prefix.archive (ar_namespace,ar_title,ar_timestamp);
154 CREATE INDEX &mw_prefix.archive_i02 ON &mw_prefix.archive (ar_user_text,ar_timestamp);
155 CREATE INDEX &mw_prefix.archive_i03 ON &mw_prefix.archive (ar_rev_id);
157 CREATE TABLE &mw_prefix.pagelinks (
158 pl_from NUMBER NOT NULL,
159 pl_namespace NUMBER DEFAULT 0 NOT NULL,
160 pl_title VARCHAR2(255) NOT NULL
162 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;
163 CREATE UNIQUE INDEX &mw_prefix.pagelinks_u01 ON &mw_prefix.pagelinks (pl_from,pl_namespace,pl_title);
164 CREATE UNIQUE INDEX &mw_prefix.pagelinks_u02 ON &mw_prefix.pagelinks (pl_namespace,pl_title,pl_from);
166 CREATE TABLE &mw_prefix.templatelinks (
167 tl_from NUMBER NOT NULL,
168 tl_namespace NUMBER DEFAULT 0 NOT NULL,
169 tl_title VARCHAR2(255) NOT NULL
171 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;
172 CREATE UNIQUE INDEX &mw_prefix.templatelinks_u01 ON &mw_prefix.templatelinks (tl_from,tl_namespace,tl_title);
173 CREATE UNIQUE INDEX &mw_prefix.templatelinks_u02 ON &mw_prefix.templatelinks (tl_namespace,tl_title,tl_from);
175 CREATE TABLE &mw_prefix.imagelinks (
176 il_from NUMBER NOT NULL,
177 il_to VARCHAR2(255) NOT NULL
179 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;
180 CREATE UNIQUE INDEX &mw_prefix.imagelinks_u01 ON &mw_prefix.imagelinks (il_from,il_to);
181 CREATE UNIQUE INDEX &mw_prefix.imagelinks_u02 ON &mw_prefix.imagelinks (il_to,il_from);
184 CREATE TABLE &mw_prefix.categorylinks (
185 cl_from NUMBER NOT NULL,
186 cl_to VARCHAR2(255) NOT NULL,
187 cl_sortkey VARCHAR2(230),
188 cl_sortkey_prefix VARCHAR2(255),
189 cl_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
190 cl_collation VARCHAR2(32),
191 cl_type VARCHAR2(6) DEFAULT 'page' NOT NULL
193 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;
194 CREATE UNIQUE INDEX &mw_prefix.categorylinks_u01 ON &mw_prefix.categorylinks (cl_from,cl_to);
195 CREATE INDEX &mw_prefix.categorylinks_i01 ON &mw_prefix.categorylinks (cl_to,cl_type,cl_sortkey,cl_from);
196 CREATE INDEX &mw_prefix.categorylinks_i02 ON &mw_prefix.categorylinks (cl_to,cl_timestamp);
197 CREATE INDEX &mw_prefix.categorylinks_i03 ON &mw_prefix.categorylinks (cl_collation);
199 CREATE SEQUENCE category_cat_id_seq;
200 CREATE TABLE &mw_prefix.category (
201 cat_id NUMBER NOT NULL,
202 cat_title VARCHAR2(255) NOT NULL,
203 cat_pages NUMBER DEFAULT 0 NOT NULL,
204 cat_subcats NUMBER DEFAULT 0 NOT NULL,
205 cat_files NUMBER DEFAULT 0 NOT NULL
207 ALTER TABLE &mw_prefix.category ADD CONSTRAINT &mw_prefix.category_pk PRIMARY KEY (cat_id);
208 CREATE UNIQUE INDEX &mw_prefix.category_u01 ON &mw_prefix.category (cat_title);
209 CREATE INDEX &mw_prefix.category_i01 ON &mw_prefix.category (cat_pages);
211 CREATE TABLE &mw_prefix.externallinks (
212 el_from NUMBER NOT NULL,
213 el_to VARCHAR2(2048) NOT NULL,
214 el_index VARCHAR2(2048) NOT NULL
216 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;
217 CREATE INDEX &mw_prefix.externallinks_i01 ON &mw_prefix.externallinks (el_from, el_to);
218 CREATE INDEX &mw_prefix.externallinks_i02 ON &mw_prefix.externallinks (el_to, el_from);
219 CREATE INDEX &mw_prefix.externallinks_i03 ON &mw_prefix.externallinks (el_index);
221 CREATE TABLE &mw_prefix.langlinks (
222 ll_from NUMBER NOT NULL,
223 ll_lang VARCHAR2(20),
224 ll_title VARCHAR2(255)
226 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;
227 CREATE UNIQUE INDEX &mw_prefix.langlinks_u01 ON &mw_prefix.langlinks (ll_from, ll_lang);
228 CREATE INDEX &mw_prefix.langlinks_i01 ON &mw_prefix.langlinks (ll_lang, ll_title);
230 CREATE TABLE &mw_prefix.iwlinks (
231 iwl_from NUMBER DEFAULT 0 NOT NULL,
232 iwl_prefix VARCHAR2(20),
233 iwl_title VARCHAR2(255)
235 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui01 ON &mw_prefix.iwlinks (iwl_from, iwl_prefix, iwl_title);
236 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui02 ON &mw_prefix.iwlinks (iwl_prefix, iwl_title, iwl_from);
238 CREATE TABLE &mw_prefix.site_stats (
239 ss_row_id NUMBER NOT NULL ,
240 ss_total_views NUMBER DEFAULT 0,
241 ss_total_edits NUMBER DEFAULT 0,
242 ss_good_articles NUMBER DEFAULT 0,
243 ss_total_pages NUMBER DEFAULT -1,
244 ss_users NUMBER DEFAULT -1,
245 ss_active_users NUMBER DEFAULT -1,
246 ss_images NUMBER DEFAULT 0
248 CREATE UNIQUE INDEX &mw_prefix.site_stats_u01 ON &mw_prefix.site_stats (ss_row_id);
250 CREATE TABLE &mw_prefix.hitcounter (
251 hc_id NUMBER NOT NULL
254 CREATE SEQUENCE ipblocks_ipb_id_seq;
255 CREATE TABLE &mw_prefix.ipblocks (
256 ipb_id NUMBER NOT NULL,
257 ipb_address VARCHAR2(255) NULL,
258 ipb_user NUMBER DEFAULT 0 NOT NULL,
259 ipb_by NUMBER DEFAULT 0 NOT NULL,
260 ipb_by_text VARCHAR2(255) NULL,
261 ipb_reason VARCHAR2(255) NOT NULL,
262 ipb_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
263 ipb_auto CHAR(1) DEFAULT '0' NOT NULL,
264 ipb_anon_only CHAR(1) DEFAULT '0' NOT NULL,
265 ipb_create_account CHAR(1) DEFAULT '1' NOT NULL,
266 ipb_enable_autoblock CHAR(1) DEFAULT '1' NOT NULL,
267 ipb_expiry TIMESTAMP(6) WITH TIME ZONE NOT NULL,
268 ipb_range_start VARCHAR2(255),
269 ipb_range_end VARCHAR2(255),
270 ipb_deleted CHAR(1) DEFAULT '0' NOT NULL,
271 ipb_block_email CHAR(1) DEFAULT '0' NOT NULL,
272 ipb_allow_usertalk CHAR(1) DEFAULT '0' NOT NULL,
273 ipb_parent_block_id NUMBER DEFAULT NULL
275 ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_pk PRIMARY KEY (ipb_id);
276 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;
277 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;
278 CREATE UNIQUE INDEX &mw_prefix.ipblocks_u01 ON &mw_prefix.ipblocks (ipb_address, ipb_user, ipb_auto, ipb_anon_only);
279 CREATE INDEX &mw_prefix.ipblocks_i01 ON &mw_prefix.ipblocks (ipb_user);
280 CREATE INDEX &mw_prefix.ipblocks_i02 ON &mw_prefix.ipblocks (ipb_range_start, ipb_range_end);
281 CREATE INDEX &mw_prefix.ipblocks_i03 ON &mw_prefix.ipblocks (ipb_timestamp);
282 CREATE INDEX &mw_prefix.ipblocks_i04 ON &mw_prefix.ipblocks (ipb_expiry);
283 CREATE INDEX &mw_prefix.ipblocks_i05 ON &mw_prefix.ipblocks (ipb_parent_block_id);
285 CREATE TABLE &mw_prefix.image (
286 img_name VARCHAR2(255) NOT NULL,
287 img_size NUMBER DEFAULT 0 NOT NULL,
288 img_width NUMBER DEFAULT 0 NOT NULL,
289 img_height NUMBER DEFAULT 0 NOT NULL,
291 img_bits NUMBER DEFAULT 0 NOT NULL,
292 img_media_type VARCHAR2(32),
293 img_major_mime VARCHAR2(32) DEFAULT 'unknown',
294 img_minor_mime VARCHAR2(100) DEFAULT 'unknown',
295 img_description VARCHAR2(255),
296 img_user NUMBER DEFAULT 0 NOT NULL,
297 img_user_text VARCHAR2(255) NOT NULL,
298 img_timestamp TIMESTAMP(6) WITH TIME ZONE,
299 img_sha1 VARCHAR2(32)
301 ALTER TABLE &mw_prefix.image ADD CONSTRAINT &mw_prefix.image_pk PRIMARY KEY (img_name);
302 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;
303 CREATE INDEX &mw_prefix.image_i01 ON &mw_prefix.image (img_user_text,img_timestamp);
304 CREATE INDEX &mw_prefix.image_i02 ON &mw_prefix.image (img_size);
305 CREATE INDEX &mw_prefix.image_i03 ON &mw_prefix.image (img_timestamp);
306 CREATE INDEX &mw_prefix.image_i04 ON &mw_prefix.image (img_sha1);
309 CREATE TABLE &mw_prefix.oldimage (
310 oi_name VARCHAR2(255) DEFAULT 0 NOT NULL,
311 oi_archive_name VARCHAR2(255),
312 oi_size NUMBER DEFAULT 0 NOT NULL,
313 oi_width NUMBER DEFAULT 0 NOT NULL,
314 oi_height NUMBER DEFAULT 0 NOT NULL,
315 oi_bits NUMBER DEFAULT 0 NOT NULL,
316 oi_description VARCHAR2(255),
317 oi_user NUMBER DEFAULT 0 NOT NULL,
318 oi_user_text VARCHAR2(255) NOT NULL,
319 oi_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
321 oi_media_type VARCHAR2(32) DEFAULT NULL,
322 oi_major_mime VARCHAR2(32) DEFAULT 'unknown',
323 oi_minor_mime VARCHAR2(100) DEFAULT 'unknown',
324 oi_deleted NUMBER DEFAULT 0 NOT NULL,
327 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;
328 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;
329 CREATE INDEX &mw_prefix.oldimage_i01 ON &mw_prefix.oldimage (oi_user_text,oi_timestamp);
330 CREATE INDEX &mw_prefix.oldimage_i02 ON &mw_prefix.oldimage (oi_name,oi_timestamp);
331 CREATE INDEX &mw_prefix.oldimage_i03 ON &mw_prefix.oldimage (oi_name,oi_archive_name);
332 CREATE INDEX &mw_prefix.oldimage_i04 ON &mw_prefix.oldimage (oi_sha1);
335 CREATE SEQUENCE filearchive_fa_id_seq;
336 CREATE TABLE &mw_prefix.filearchive (
337 fa_id NUMBER NOT NULL,
338 fa_name VARCHAR2(255) NOT NULL,
339 fa_archive_name VARCHAR2(255),
340 fa_storage_group VARCHAR2(16),
341 fa_storage_key VARCHAR2(64),
342 fa_deleted_user NUMBER DEFAULT 0 NOT NULL,
343 fa_deleted_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
344 fa_deleted_reason CLOB,
345 fa_size NUMBER DEFAULT 0 NOT NULL,
346 fa_width NUMBER DEFAULT 0 NOT NULL,
347 fa_height NUMBER DEFAULT 0 NOT NULL,
349 fa_bits NUMBER DEFAULT 0 NOT NULL,
350 fa_media_type VARCHAR2(32) DEFAULT NULL,
351 fa_major_mime VARCHAR2(32) DEFAULT 'unknown',
352 fa_minor_mime VARCHAR2(100) DEFAULT 'unknown',
353 fa_description VARCHAR2(255),
354 fa_user NUMBER DEFAULT 0 NOT NULL,
355 fa_user_text VARCHAR2(255) NOT NULL,
356 fa_timestamp TIMESTAMP(6) WITH TIME ZONE,
357 fa_deleted NUMBER DEFAULT 0 NOT NULL,
360 ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_pk PRIMARY KEY (fa_id);
361 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;
362 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;
363 CREATE INDEX &mw_prefix.filearchive_i01 ON &mw_prefix.filearchive (fa_name, fa_timestamp);
364 CREATE INDEX &mw_prefix.filearchive_i02 ON &mw_prefix.filearchive (fa_storage_group, fa_storage_key);
365 CREATE INDEX &mw_prefix.filearchive_i03 ON &mw_prefix.filearchive (fa_deleted_timestamp);
366 CREATE INDEX &mw_prefix.filearchive_i04 ON &mw_prefix.filearchive (fa_user_text,fa_timestamp);
367 CREATE INDEX &mw_prefix.filearchive_i05 ON &mw_prefix.filearchive (fa_sha1);
369 CREATE SEQUENCE uploadstash_us_id_seq;
370 CREATE TABLE &mw_prefix.uploadstash (
371 us_id NUMBER NOT NULL,
372 us_user NUMBER DEFAULT 0 NOT NULL,
373 us_key VARCHAR2(255) NOT NULL,
374 us_orig_path VARCHAR2(255) NOT NULL,
375 us_path VARCHAR2(255) NOT NULL,
376 us_source_type VARCHAR2(50),
377 us_timestamp TIMESTAMP(6) WITH TIME ZONE,
378 us_status VARCHAR2(50) NOT NULL,
380 us_size NUMBER NOT NULL,
381 us_sha1 VARCHAR2(32) NOT NULL,
382 us_mime VARCHAR2(255),
383 us_media_type VARCHAR2(32) DEFAULT NULL,
384 us_image_width NUMBER,
385 us_image_height NUMBER,
386 us_image_bits NUMBER,
389 ALTER TABLE &mw_prefix.uploadstash ADD CONSTRAINT &mw_prefix.uploadstash_pk PRIMARY KEY (us_id);
390 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;
391 CREATE INDEX &mw_prefix.uploadstash_i01 ON &mw_prefix.uploadstash (us_user);
392 CREATE INDEX &mw_prefix.uploadstash_i02 ON &mw_prefix.uploadstash (us_timestamp);
393 CREATE UNIQUE INDEX &mw_prefix.uploadstash_u01 ON &mw_prefix.uploadstash (us_key);
395 CREATE SEQUENCE recentchanges_rc_id_seq;
396 CREATE TABLE &mw_prefix.recentchanges (
397 rc_id NUMBER NOT NULL,
398 rc_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
399 rc_cur_time TIMESTAMP(6) WITH TIME ZONE NOT NULL,
400 rc_user NUMBER DEFAULT 0 NOT NULL,
401 rc_user_text VARCHAR2(255) NOT NULL,
402 rc_namespace NUMBER DEFAULT 0 NOT NULL,
403 rc_title VARCHAR2(255) NOT NULL,
404 rc_comment VARCHAR2(255),
405 rc_minor CHAR(1) DEFAULT '0' NOT NULL,
406 rc_bot CHAR(1) DEFAULT '0' NOT NULL,
407 rc_new CHAR(1) DEFAULT '0' NOT NULL,
408 rc_cur_id NUMBER DEFAULT 0 NOT NULL,
409 rc_this_oldid NUMBER DEFAULT 0 NOT NULL,
410 rc_last_oldid NUMBER DEFAULT 0 NOT NULL,
411 rc_type CHAR(1) DEFAULT '0' NOT NULL,
412 rc_moved_to_ns NUMBER DEFAULT 0 NOT NULL,
413 rc_moved_to_title VARCHAR2(255),
414 rc_patrolled CHAR(1) DEFAULT '0' NOT NULL,
418 rc_deleted CHAR(1) DEFAULT '0' NOT NULL,
419 rc_logid NUMBER DEFAULT 0 NOT NULL,
420 rc_log_type VARCHAR2(255),
421 rc_log_action VARCHAR2(255),
424 ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_pk PRIMARY KEY (rc_id);
425 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;
426 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;
427 CREATE INDEX &mw_prefix.recentchanges_i01 ON &mw_prefix.recentchanges (rc_timestamp);
428 CREATE INDEX &mw_prefix.recentchanges_i02 ON &mw_prefix.recentchanges (rc_namespace, rc_title);
429 CREATE INDEX &mw_prefix.recentchanges_i03 ON &mw_prefix.recentchanges (rc_cur_id);
430 CREATE INDEX &mw_prefix.recentchanges_i04 ON &mw_prefix.recentchanges (rc_new,rc_namespace,rc_timestamp);
431 CREATE INDEX &mw_prefix.recentchanges_i05 ON &mw_prefix.recentchanges (rc_ip);
432 CREATE INDEX &mw_prefix.recentchanges_i06 ON &mw_prefix.recentchanges (rc_namespace, rc_user_text);
433 CREATE INDEX &mw_prefix.recentchanges_i07 ON &mw_prefix.recentchanges (rc_user_text, rc_timestamp);
435 CREATE TABLE &mw_prefix.watchlist (
436 wl_user NUMBER NOT NULL,
437 wl_namespace NUMBER DEFAULT 0 NOT NULL,
438 wl_title VARCHAR2(255) NOT NULL,
439 wl_notificationtimestamp TIMESTAMP(6) WITH TIME ZONE
441 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;
442 CREATE UNIQUE INDEX &mw_prefix.watchlist_u01 ON &mw_prefix.watchlist (wl_user, wl_namespace, wl_title);
443 CREATE INDEX &mw_prefix.watchlist_i01 ON &mw_prefix.watchlist (wl_namespace, wl_title);
446 CREATE TABLE &mw_prefix.searchindex (
447 si_page NUMBER NOT NULL,
448 si_title VARCHAR2(255),
449 si_text CLOB NOT NULL
451 CREATE UNIQUE INDEX &mw_prefix.searchindex_u01 ON &mw_prefix.searchindex (si_page);
453 CREATE TABLE &mw_prefix.interwiki (
454 iw_prefix VARCHAR2(32) NOT NULL,
455 iw_url VARCHAR2(127) NOT NULL,
456 iw_api BLOB NOT NULL,
457 iw_wikiid VARCHAR2(64),
458 iw_local CHAR(1) NOT NULL,
459 iw_trans CHAR(1) DEFAULT '0' NOT NULL
461 CREATE UNIQUE INDEX &mw_prefix.interwiki_u01 ON &mw_prefix.interwiki (iw_prefix);
463 CREATE TABLE &mw_prefix.querycache (
464 qc_type VARCHAR2(32) NOT NULL,
465 qc_value NUMBER DEFAULT 0 NOT NULL,
466 qc_namespace NUMBER DEFAULT 0 NOT NULL,
467 qc_title VARCHAR2(255) NOT NULL
469 CREATE INDEX &mw_prefix.querycache_u01 ON &mw_prefix.querycache (qc_type,qc_value);
471 CREATE TABLE &mw_prefix.objectcache (
472 keyname VARCHAR2(255) ,
474 exptime TIMESTAMP(6) WITH TIME ZONE NOT NULL
476 CREATE INDEX &mw_prefix.objectcache_i01 ON &mw_prefix.objectcache (exptime);
478 CREATE TABLE &mw_prefix.transcache (
479 tc_url VARCHAR2(255) NOT NULL,
480 tc_contents CLOB NOT NULL,
481 tc_time TIMESTAMP(6) WITH TIME ZONE NOT NULL
483 CREATE UNIQUE INDEX &mw_prefix.transcache_u01 ON &mw_prefix.transcache (tc_url);
486 CREATE SEQUENCE logging_log_id_seq;
487 CREATE TABLE &mw_prefix.logging (
488 log_id NUMBER NOT NULL,
489 log_type VARCHAR2(10) NOT NULL,
490 log_action VARCHAR2(10) NOT NULL,
491 log_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
492 log_user NUMBER DEFAULT 0 NOT NULL,
493 log_user_text VARCHAR2(255),
494 log_namespace NUMBER DEFAULT 0 NOT NULL,
495 log_title VARCHAR2(255) NOT NULL,
497 log_comment VARCHAR2(255),
499 log_deleted CHAR(1) DEFAULT '0' NOT NULL
501 ALTER TABLE &mw_prefix.logging ADD CONSTRAINT &mw_prefix.logging_pk PRIMARY KEY (log_id);
502 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;
503 CREATE INDEX &mw_prefix.logging_i01 ON &mw_prefix.logging (log_type, log_timestamp);
504 CREATE INDEX &mw_prefix.logging_i02 ON &mw_prefix.logging (log_user, log_timestamp);
505 CREATE INDEX &mw_prefix.logging_i03 ON &mw_prefix.logging (log_namespace, log_title, log_timestamp);
506 CREATE INDEX &mw_prefix.logging_i04 ON &mw_prefix.logging (log_timestamp);
507 CREATE INDEX &mw_prefix.logging_i05 ON &mw_prefix.logging (log_type, log_action, log_timestamp);
509 CREATE TABLE &mw_prefix.log_search (
510 ls_field VARCHAR2(32) NOT NULL,
511 ls_value VARCHAR2(255) NOT NULL,
512 ls_log_id NuMBER DEFAULT 0 NOT NULL
514 ALTER TABLE &mw_prefix.log_search ADD CONSTRAINT log_search_pk PRIMARY KEY (ls_field,ls_value,ls_log_id);
515 CREATE INDEX &mw_prefix.log_search_i01 ON &mw_prefix.log_search (ls_log_id);
518 CREATE SEQUENCE job_job_id_seq;
519 CREATE TABLE &mw_prefix.job (
520 job_id NUMBER NOT NULL,
521 job_cmd VARCHAR2(60) NOT NULL,
522 job_namespace NUMBER DEFAULT 0 NOT NULL,
523 job_title VARCHAR2(255) NOT NULL,
524 job_timestamp TIMESTAMP(6) WITH TIME ZONE NULL,
525 job_params CLOB NOT NULL,
526 job_random NUMBER DEFAULT 0 NOT NULL,
527 job_token VARCHAR2(32),
528 job_token_timestamp TIMESTAMP(6) WITH TIME ZONE,
529 job_sha1 VARCHAR2(32),
530 job_attempts NUMBER DEFAULT 0 NOT NULL
532 ALTER TABLE &mw_prefix.job ADD CONSTRAINT &mw_prefix.job_pk PRIMARY KEY (job_id);
533 CREATE INDEX &mw_prefix.job_i01 ON &mw_prefix.job (job_cmd, job_namespace, job_title);
534 CREATE INDEX &mw_prefix.job_i02 ON &mw_prefix.job (job_timestamp);
535 CREATE INDEX &mw_prefix.job_i03 ON &mw_prefix.job (job_sha1);
536 CREATE INDEX &mw_prefix.job_i04 ON &mw_prefix.job (job_cmd,job_token,job_random);
537 CREATE INDEX &mw_prefix.job_i05 ON &mw_prefix.job (job_attempts);
539 CREATE TABLE &mw_prefix.querycache_info (
540 qci_type VARCHAR2(32) NOT NULL,
541 qci_timestamp TIMESTAMP(6) WITH TIME ZONE NULL
543 CREATE UNIQUE INDEX &mw_prefix.querycache_info_u01 ON &mw_prefix.querycache_info (qci_type);
545 CREATE TABLE &mw_prefix.redirect (
546 rd_from NUMBER NOT NULL,
547 rd_namespace NUMBER DEFAULT 0 NOT NULL,
548 rd_title VARCHAR2(255) NOT NULL,
549 rd_interwiki VARCHAR2(32),
550 rd_fragment VARCHAR2(255)
552 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;
553 CREATE INDEX &mw_prefix.redirect_i01 ON &mw_prefix.redirect (rd_namespace,rd_title,rd_from);
555 CREATE TABLE &mw_prefix.querycachetwo (
556 qcc_type VARCHAR2(32) NOT NULL,
557 qcc_value NUMBER DEFAULT 0 NOT NULL,
558 qcc_namespace NUMBER DEFAULT 0 NOT NULL,
559 qcc_title VARCHAR2(255),
560 qcc_namespacetwo NUMBER DEFAULT 0 NOT NULL,
561 qcc_titletwo VARCHAR2(255)
563 CREATE INDEX &mw_prefix.querycachetwo_i01 ON &mw_prefix.querycachetwo (qcc_type,qcc_value);
564 CREATE INDEX &mw_prefix.querycachetwo_i02 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespace,qcc_title);
565 CREATE INDEX &mw_prefix.querycachetwo_i03 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
567 CREATE SEQUENCE page_restrictions_pr_id_seq;
568 CREATE TABLE &mw_prefix.page_restrictions (
569 pr_id NUMBER NOT NULL,
570 pr_page NUMBER NOT NULL,
571 pr_type VARCHAR2(255) NOT NULL,
572 pr_level VARCHAR2(255) NOT NULL,
573 pr_cascade NUMBER NOT NULL,
575 pr_expiry TIMESTAMP(6) WITH TIME ZONE NULL
577 ALTER TABLE &mw_prefix.page_restrictions ADD CONSTRAINT &mw_prefix.page_restrictions_pk PRIMARY KEY (pr_id);
578 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;
579 CREATE UNIQUE INDEX &mw_prefix.page_restrictions_u01 ON &mw_prefix.page_restrictions (pr_page,pr_type);
580 CREATE INDEX &mw_prefix.page_restrictions_i01 ON &mw_prefix.page_restrictions (pr_type,pr_level);
581 CREATE INDEX &mw_prefix.page_restrictions_i02 ON &mw_prefix.page_restrictions (pr_level);
582 CREATE INDEX &mw_prefix.page_restrictions_i03 ON &mw_prefix.page_restrictions (pr_cascade);
584 CREATE TABLE &mw_prefix.protected_titles (
585 pt_namespace NUMBER DEFAULT 0 NOT NULL,
586 pt_title VARCHAR2(255) NOT NULL,
587 pt_user NUMBER NOT NULL,
588 pt_reason VARCHAR2(255),
589 pt_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
590 pt_expiry VARCHAR2(14) NOT NULL,
591 pt_create_perm VARCHAR2(60) NOT NULL
593 CREATE UNIQUE INDEX &mw_prefix.protected_titles_u01 ON &mw_prefix.protected_titles (pt_namespace,pt_title);
594 CREATE INDEX &mw_prefix.protected_titles_i01 ON &mw_prefix.protected_titles (pt_timestamp);
596 CREATE TABLE &mw_prefix.page_props (
597 pp_page NUMBER NOT NULL,
598 pp_propname VARCHAR2(60) NOT NULL,
599 pp_value BLOB NOT NULL
601 CREATE UNIQUE INDEX &mw_prefix.page_props_u01 ON &mw_prefix.page_props (pp_page,pp_propname);
604 CREATE TABLE &mw_prefix.updatelog (
605 ul_key VARCHAR2(255) NOT NULL,
608 ALTER TABLE &mw_prefix.updatelog ADD CONSTRAINT &mw_prefix.updatelog_pk PRIMARY KEY (ul_key);
610 CREATE TABLE &mw_prefix.change_tag (
611 ct_rc_id NUMBER NULL,
612 ct_log_id NUMBER NULL,
613 ct_rev_id NUMBER NULL,
614 ct_tag VARCHAR2(255) NOT NULL,
617 CREATE UNIQUE INDEX &mw_prefix.change_tag_u01 ON &mw_prefix.change_tag (ct_rc_id,ct_tag);
618 CREATE UNIQUE INDEX &mw_prefix.change_tag_u02 ON &mw_prefix.change_tag (ct_log_id,ct_tag);
619 CREATE UNIQUE INDEX &mw_prefix.change_tag_u03 ON &mw_prefix.change_tag (ct_rev_id,ct_tag);
620 CREATE INDEX &mw_prefix.change_tag_i01 ON &mw_prefix.change_tag (ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
622 CREATE TABLE &mw_prefix.tag_summary (
623 ts_rc_id NUMBER NULL,
624 ts_log_id NUMBER NULL,
625 ts_rev_id NUMBER NULL,
626 ts_tags BLOB NOT NULL
628 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u01 ON &mw_prefix.tag_summary (ts_rc_id);
629 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u02 ON &mw_prefix.tag_summary (ts_log_id);
630 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u03 ON &mw_prefix.tag_summary (ts_rev_id);
632 CREATE TABLE &mw_prefix.valid_tag (
633 vt_tag VARCHAR2(255) NOT NULL
635 ALTER TABLE &mw_prefix.valid_tag ADD CONSTRAINT &mw_prefix.valid_tag_pk PRIMARY KEY (vt_tag);
637 -- This table is not used unless profiling is turned on
638 --CREATE TABLE &mw_prefix.profiling (
639 -- pf_count NUMBER DEFAULT 0 NOT NULL,
640 -- pf_time NUMERIC(18,10) DEFAULT 0 NOT NULL,
641 -- pf_name CLOB NOT NULL,
642 -- pf_server CLOB NULL
644 --CREATE UNIQUE INDEX &mw_prefix.profiling_u01 ON &mw_prefix.profiling (pf_name, pf_server);
646 CREATE INDEX &mw_prefix.si_title_idx ON &mw_prefix.searchindex(si_title) INDEXTYPE IS ctxsys.context;
647 CREATE INDEX &mw_prefix.si_text_idx ON &mw_prefix.searchindex(si_text) INDEXTYPE IS ctxsys.context;
649 CREATE TABLE &mw_prefix.l10n_cache (
650 lc_lang varchar2(32) NOT NULL,
651 lc_key varchar2(255) NOT NULL,
652 lc_value clob NOT NULL
654 CREATE INDEX &mw_prefix.l10n_cache_u01 ON &mw_prefix.l10n_cache (lc_lang, lc_key);
656 CREATE TABLE &mw_prefix.msg_resource (
657 mr_resource VARCHAR2(255) NOT NULL,
658 mr_lang varchar2(32) NOT NULL,
659 mr_blob BLOB NOT NULL,
660 mr_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL
662 CREATE UNIQUE INDEX &mw_prefix.msg_resource_u01 ON &mw_prefix.msg_resource (mr_resource, mr_lang);
664 CREATE TABLE &mw_prefix.msg_resource_links (
665 mrl_resource VARCHAR2(255) NOT NULL,
666 mrl_message VARCHAR2(255) NOT NULL
668 CREATE UNIQUE INDEX &mw_prefix.msg_resource_links_u01 ON &mw_prefix.msg_resource_links (mrl_message, mrl_resource);
670 CREATE TABLE &mw_prefix.module_deps (
671 md_module VARCHAR2(255) NOT NULL,
672 md_skin VARCHAR2(32) NOT NULL,
673 md_deps BLOB NOT NULL
675 CREATE UNIQUE INDEX &mw_prefix.module_deps_u01 ON &mw_prefix.module_deps (md_module, md_skin);
677 CREATE SEQUENCE sites_site_id_seq MINVALUE 0 START WITH 0;
678 CREATE TABLE &mw_prefix.sites (
679 site_id NUMBER NOT NULL,
680 site_global_key VARCHAR2(32) NOT NULL,
681 site_type VARCHAR2(32) NOT NULL,
682 site_group VARCHAR2(32) NOT NULL,
683 site_source VARCHAR2(32) NOT NULL,
684 site_language VARCHAR2(32) NOT NULL,
685 site_protocol VARCHAR2(32) NOT NULL,
686 site_domain VARCHAR2(255) NOT NULL,
687 site_data BLOB NOT NULL,
688 site_forward NUMBER(1) NOT NULL,
689 site_config BLOB NOT NULL
691 ALTER TABLE &mw_prefix.sites ADD CONSTRAINT &mw_prefix.sites_pk PRIMARY KEY (site_id);
692 CREATE UNIQUE INDEX &mw_prefix.sites_u01 ON &mw_prefix.sites (site_global_key);
693 CREATE INDEX &mw_prefix.sites_i01 ON &mw_prefix.sites (site_type);
694 CREATE INDEX &mw_prefix.sites_i02 ON &mw_prefix.sites (site_group);
695 CREATE INDEX &mw_prefix.sites_i03 ON &mw_prefix.sites (site_source);
696 CREATE INDEX &mw_prefix.sites_i04 ON &mw_prefix.sites (site_language);
697 CREATE INDEX &mw_prefix.sites_i05 ON &mw_prefix.sites (site_protocol);
698 CREATE INDEX &mw_prefix.sites_i06 ON &mw_prefix.sites (site_domain);
699 CREATE INDEX &mw_prefix.sites_i07 ON &mw_prefix.sites (site_forward);
701 CREATE TABLE &mw_prefix.site_identifiers (
702 si_site NUMBER NOT NULL,
703 si_type VARCHAR2(32) NOT NULL,
704 si_key VARCHAR2(32) NOT NULL
706 CREATE UNIQUE INDEX &mw_prefix.site_identifiers_u01 ON &mw_prefix.site_identifiers (si_type, si_key);
707 CREATE INDEX &mw_prefix.site_identifiers_i01 ON &mw_prefix.site_identifiers (si_site);
708 CREATE INDEX &mw_prefix.site_identifiers_i02 ON &mw_prefix.site_identifiers (si_key);
710 -- do not prefix this table as it breaks parserTests
711 CREATE TABLE wiki_field_info_full (
712 table_name VARCHAR2(35) NOT NULL,
713 column_name VARCHAR2(35) NOT NULL,
714 data_default VARCHAR2(4000),
715 data_length NUMBER NOT NULL,
716 data_type VARCHAR2(106),
717 not_null CHAR(1) NOT NULL,
722 ALTER TABLE wiki_field_info_full ADD CONSTRAINT wiki_field_info_full_pk PRIMARY KEY (table_name, column_name);
725 CREATE PROCEDURE fill_wiki_info IS
727 DELETE wiki_field_info_full;
729 FOR x_rec IN (SELECT t.table_name table_name, t.column_name,
730 t.data_default, t.data_length, t.data_type,
731 DECODE (t.nullable, 'Y', '1', 'N', '0') not_null,
733 FROM user_cons_columns ucc,
735 WHERE ucc.table_name = t.table_name
736 AND ucc.column_name = t.column_name
737 AND uc.constraint_name = ucc.constraint_name
738 AND uc.constraint_type = 'P'
739 AND ROWNUM < 2) prim,
741 FROM user_ind_columns uic,
743 WHERE uic.table_name = t.table_name
744 AND uic.column_name = t.column_name
745 AND ui.index_name = uic.index_name
746 AND ui.uniqueness = 'UNIQUE'
747 AND ROWNUM < 2) uniq,
749 FROM user_ind_columns uic,
751 WHERE uic.table_name = t.table_name
752 AND uic.column_name = t.column_name
753 AND ui.index_name = uic.index_name
754 AND ui.uniqueness = 'NONUNIQUE'
755 AND ROWNUM < 2) nonuniq
756 FROM user_tab_columns t, user_tables ut
757 WHERE ut.table_name = t.table_name)
759 INSERT INTO wiki_field_info_full
760 (table_name, column_name,
761 data_default, data_length,
762 data_type, not_null, prim,
765 VALUES (x_rec.table_name, x_rec.column_name,
766 x_rec.data_default, x_rec.data_length,
767 x_rec.data_type, x_rec.not_null, x_rec.prim,
768 x_rec.uniq, x_rec.nonuniq
776 CREATE OR REPLACE PROCEDURE duplicate_table(p_tabname IN VARCHAR2,
777 p_oldprefix IN VARCHAR2,
778 p_newprefix IN VARCHAR2,
779 p_temporary IN BOOLEAN) IS
780 e_table_not_exist EXCEPTION;
781 PRAGMA EXCEPTION_INIT(e_table_not_exist, -00942);
782 l_temp_ei_sql VARCHAR2(2000);
783 l_temporary BOOLEAN := p_temporary;
786 EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname ||
787 ' CASCADE CONSTRAINTS PURGE';
789 WHEN e_table_not_exist THEN
792 IF (p_tabname = 'SEARCHINDEX') THEN
793 l_temporary := FALSE;
795 IF (l_temporary) THEN
796 EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix ||
798 ' ON COMMIT PRESERVE ROWS AS SELECT * FROM ' ||
799 p_oldprefix || p_tabname || ' WHERE ROWNUM = 0';
801 EXECUTE IMMEDIATE 'CREATE TABLE ' || p_newprefix || p_tabname ||
802 ' AS SELECT * FROM ' || p_oldprefix || p_tabname ||
805 FOR rc IN (SELECT column_name, data_default
806 FROM user_tab_columns
807 WHERE table_name = p_oldprefix || p_tabname
808 AND data_default IS NOT NULL) LOOP
809 EXECUTE IMMEDIATE 'ALTER TABLE ' || p_newprefix || p_tabname ||
810 ' MODIFY ' || rc.column_name || ' DEFAULT ' ||
811 SUBSTR(rc.data_default, 1, 2000);
813 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('CONSTRAINT',
817 USER || '"."' || p_oldprefix,
818 USER || '"."' || p_newprefix),
819 '"' || constraint_name || '"',
820 '"' || p_newprefix || constraint_name || '"') DDLVC2,
822 FROM user_constraints uc
823 WHERE table_name = p_oldprefix || p_tabname
824 AND constraint_type = 'P') LOOP
825 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
826 l_temp_ei_sql := SUBSTR(l_temp_ei_sql,
830 INSTR(l_temp_ei_sql, 'PRIMARY KEY') + 1) + 1);
831 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
832 EXECUTE IMMEDIATE l_temp_ei_sql;
835 IF (NOT l_temporary) THEN
836 FOR rc IN (SELECT REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('REF_CONSTRAINT',
840 USER || '"."' || p_oldprefix,
841 USER || '"."' || p_newprefix) DDLVC2,
843 FROM user_constraints uc
844 WHERE table_name = p_oldprefix || p_tabname
845 AND constraint_type = 'R') LOOP
846 IF nvl(length(l_temp_ei_sql), 0) > 0 AND
847 INSTR(l_temp_ei_sql, 'PRIMARY KEY') = 0 THEN
848 EXECUTE IMMEDIATE l_temp_ei_sql;
852 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
856 USER || '"."' || p_oldprefix,
857 USER || '"."' || p_newprefix),
858 '"' || index_name || '"',
859 '"' || p_newprefix || index_name || '"') DDLVC2,
863 WHERE table_name = p_oldprefix || p_tabname
864 AND index_type NOT IN ('LOB', 'DOMAIN')
867 FROM user_constraints
868 WHERE table_name = ui.table_name
869 AND constraint_name = ui.index_name)) LOOP
870 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
871 l_temp_ei_sql := SUBSTR(l_temp_ei_sql,
876 '"' || USER || '"."' || p_newprefix || '"') + 1) + 1);
877 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
878 EXECUTE IMMEDIATE l_temp_ei_sql;
881 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
885 USER || '"."' || p_oldprefix,
886 USER || '"."' || p_newprefix),
887 '"' || index_name || '"',
888 '"' || p_newprefix || index_name || '"') DDLVC2,
892 WHERE table_name = p_oldprefix || p_tabname
893 AND index_type = 'DOMAIN'
896 FROM user_constraints
897 WHERE table_name = ui.table_name
898 AND constraint_name = ui.index_name)) LOOP
899 l_temp_ei_sql := rc.ddlvc2;
900 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
901 EXECUTE IMMEDIATE l_temp_ei_sql;
904 FOR rc IN (SELECT REPLACE(REPLACE(UPPER(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('TRIGGER',
908 USER || '"."' || p_oldprefix,
909 USER || '"."' || p_newprefix),
910 ' ON ' || p_oldprefix || p_tabname,
911 ' ON ' || p_newprefix || p_tabname) DDLVC2,
914 WHERE table_name = p_oldprefix || p_tabname) LOOP
915 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'ALTER ') - 1);
916 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
917 EXECUTE IMMEDIATE l_temp_ei_sql;
925 CREATE OR REPLACE FUNCTION BITOR (x IN NUMBER, y IN NUMBER) RETURN NUMBER AS
927 RETURN (x + y - BITAND(x, y));
932 CREATE OR REPLACE FUNCTION BITNOT (x IN NUMBER) RETURN NUMBER AS
934 RETURN (4294967295 - x);
938 CREATE OR REPLACE TYPE GET_OUTPUT_TYPE IS TABLE OF VARCHAR2(255);
941 CREATE OR REPLACE FUNCTION GET_OUTPUT_LINES RETURN GET_OUTPUT_TYPE PIPELINED AS
942 v_line VARCHAR2(255);
943 v_status INTEGER := 0;
947 DBMS_OUTPUT.GET_LINE(v_line, v_status);
948 IF (v_status = 0) THEN RETURN; END IF;
959 CREATE OR REPLACE FUNCTION GET_SEQUENCE_VALUE(seq IN VARCHAR2) RETURN NUMBER AS
962 EXECUTE IMMEDIATE 'SELECT '||seq||'.NEXTVAL INTO :outVar FROM DUAL' INTO v_value;