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_is_redirect CHAR(1) DEFAULT '0' NOT NULL,
73 page_is_new CHAR(1) DEFAULT '0' NOT NULL,
74 page_random NUMBER(15,14) NOT NULL,
75 page_touched TIMESTAMP(6) WITH TIME ZONE,
76 page_links_updated TIMESTAMP(6) WITH TIME ZONE,
77 page_latest NUMBER DEFAULT 0 NOT NULL, -- FK?
78 page_len NUMBER DEFAULT 0 NOT NULL,
79 page_content_model VARCHAR2(32),
80 page_lang VARCHAR2(35) DEFAULT NULL
82 ALTER TABLE &mw_prefix.page ADD CONSTRAINT &mw_prefix.page_pk PRIMARY KEY (page_id);
83 CREATE UNIQUE INDEX &mw_prefix.page_u01 ON &mw_prefix.page (page_namespace,page_title);
84 CREATE INDEX &mw_prefix.page_i01 ON &mw_prefix.page (page_random);
85 CREATE INDEX &mw_prefix.page_i02 ON &mw_prefix.page (page_len);
86 CREATE INDEX &mw_prefix.page_i03 ON &mw_prefix.page (page_is_redirect, page_namespace, page_len);
88 -- Create a dummy page to satisfy fk contraints especially with revisions
89 INSERT INTO &mw_prefix.page
90 VALUES (0, 0, ' ', NULL, 0, 0, 0, current_timestamp, NULL, 0, 0, NULL, NULL);
93 CREATE TRIGGER &mw_prefix.page_set_random BEFORE INSERT ON &mw_prefix.page
94 FOR EACH ROW WHEN (new.page_random IS NULL)
96 SELECT dbms_random.value INTO :NEW.page_random FROM dual;
100 CREATE SEQUENCE revision_rev_id_seq;
101 CREATE TABLE &mw_prefix.revision (
102 rev_id NUMBER NOT NULL,
103 rev_page NUMBER NOT NULL,
104 rev_text_id NUMBER NULL,
105 rev_comment VARCHAR2(255),
106 rev_user NUMBER DEFAULT 0 NOT NULL,
107 rev_user_text VARCHAR2(255) NOT NULL,
108 rev_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
109 rev_minor_edit CHAR(1) DEFAULT '0' NOT NULL,
110 rev_deleted CHAR(1) DEFAULT '0' NOT NULL,
112 rev_parent_id NUMBER DEFAULT NULL,
113 rev_sha1 VARCHAR2(32) NULL,
114 rev_content_model VARCHAR2(32),
115 rev_content_format VARCHAR2(64)
117 ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_pk PRIMARY KEY (rev_id);
118 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;
119 ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_fk2 FOREIGN KEY (rev_user) REFERENCES &mw_prefix.mwuser(user_id) DEFERRABLE INITIALLY DEFERRED;
120 CREATE UNIQUE INDEX &mw_prefix.revision_u01 ON &mw_prefix.revision (rev_page, rev_id);
121 CREATE INDEX &mw_prefix.revision_i01 ON &mw_prefix.revision (rev_timestamp);
122 CREATE INDEX &mw_prefix.revision_i02 ON &mw_prefix.revision (rev_page,rev_timestamp);
123 CREATE INDEX &mw_prefix.revision_i03 ON &mw_prefix.revision (rev_user,rev_timestamp);
124 CREATE INDEX &mw_prefix.revision_i04 ON &mw_prefix.revision (rev_user_text,rev_timestamp);
125 CREATE INDEX &mw_prefix.revision_i05 ON &mw_prefix.revision (rev_page,rev_user,rev_timestamp);
127 CREATE SEQUENCE text_old_id_seq;
128 CREATE TABLE &mw_prefix.pagecontent ( -- replaces reserved word 'text'
129 old_id NUMBER NOT NULL,
131 old_flags VARCHAR2(255)
133 ALTER TABLE &mw_prefix.pagecontent ADD CONSTRAINT &mw_prefix.pagecontent_pk PRIMARY KEY (old_id);
135 CREATE SEQUENCE archive_ar_id_seq;
136 CREATE TABLE &mw_prefix.archive (
137 ar_id NUMBER NOT NULL,
138 ar_namespace NUMBER DEFAULT 0 NOT NULL,
139 ar_title VARCHAR2(255) NOT NULL,
141 ar_comment VARCHAR2(255),
142 ar_user NUMBER DEFAULT 0 NOT NULL,
143 ar_user_text VARCHAR2(255) NOT NULL,
144 ar_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
145 ar_minor_edit CHAR(1) DEFAULT '0' NOT NULL,
146 ar_flags VARCHAR2(255),
149 ar_deleted CHAR(1) DEFAULT '0' NOT NULL,
153 ar_sha1 VARCHAR2(32),
154 ar_content_model VARCHAR2(32),
155 ar_content_format VARCHAR2(64)
157 ALTER TABLE &mw_prefix.archive ADD CONSTRAINT &mw_prefix.archive_pk PRIMARY KEY (ar_id);
158 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;
159 CREATE INDEX &mw_prefix.archive_i01 ON &mw_prefix.archive (ar_namespace,ar_title,ar_timestamp);
160 CREATE INDEX &mw_prefix.archive_i02 ON &mw_prefix.archive (ar_user_text,ar_timestamp);
161 CREATE INDEX &mw_prefix.archive_i03 ON &mw_prefix.archive (ar_rev_id);
163 CREATE TABLE &mw_prefix.pagelinks (
164 pl_from NUMBER NOT NULL,
165 pl_namespace NUMBER DEFAULT 0 NOT NULL,
166 pl_title VARCHAR2(255) NOT NULL
168 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;
169 CREATE UNIQUE INDEX &mw_prefix.pagelinks_u01 ON &mw_prefix.pagelinks (pl_from,pl_namespace,pl_title);
170 CREATE UNIQUE INDEX &mw_prefix.pagelinks_u02 ON &mw_prefix.pagelinks (pl_namespace,pl_title,pl_from);
172 CREATE TABLE &mw_prefix.templatelinks (
173 tl_from NUMBER NOT NULL,
174 tl_namespace NUMBER DEFAULT 0 NOT NULL,
175 tl_title VARCHAR2(255) NOT NULL
177 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;
178 CREATE UNIQUE INDEX &mw_prefix.templatelinks_u01 ON &mw_prefix.templatelinks (tl_from,tl_namespace,tl_title);
179 CREATE UNIQUE INDEX &mw_prefix.templatelinks_u02 ON &mw_prefix.templatelinks (tl_namespace,tl_title,tl_from);
181 CREATE TABLE &mw_prefix.imagelinks (
182 il_from NUMBER NOT NULL,
183 il_to VARCHAR2(255) NOT NULL
185 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;
186 CREATE UNIQUE INDEX &mw_prefix.imagelinks_u01 ON &mw_prefix.imagelinks (il_from,il_to);
187 CREATE UNIQUE INDEX &mw_prefix.imagelinks_u02 ON &mw_prefix.imagelinks (il_to,il_from);
190 CREATE TABLE &mw_prefix.categorylinks (
191 cl_from NUMBER NOT NULL,
192 cl_to VARCHAR2(255) NOT NULL,
193 cl_sortkey VARCHAR2(230),
194 cl_sortkey_prefix VARCHAR2(255),
195 cl_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
196 cl_collation VARCHAR2(32),
197 cl_type VARCHAR2(6) DEFAULT 'page' NOT NULL
199 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;
200 CREATE UNIQUE INDEX &mw_prefix.categorylinks_u01 ON &mw_prefix.categorylinks (cl_from,cl_to);
201 CREATE INDEX &mw_prefix.categorylinks_i01 ON &mw_prefix.categorylinks (cl_to,cl_type,cl_sortkey,cl_from);
202 CREATE INDEX &mw_prefix.categorylinks_i02 ON &mw_prefix.categorylinks (cl_to,cl_timestamp);
203 CREATE INDEX &mw_prefix.categorylinks_i03 ON &mw_prefix.categorylinks (cl_collation);
205 CREATE SEQUENCE category_cat_id_seq;
206 CREATE TABLE &mw_prefix.category (
207 cat_id NUMBER NOT NULL,
208 cat_title VARCHAR2(255) NOT NULL,
209 cat_pages NUMBER DEFAULT 0 NOT NULL,
210 cat_subcats NUMBER DEFAULT 0 NOT NULL,
211 cat_files NUMBER DEFAULT 0 NOT NULL
213 ALTER TABLE &mw_prefix.category ADD CONSTRAINT &mw_prefix.category_pk PRIMARY KEY (cat_id);
214 CREATE UNIQUE INDEX &mw_prefix.category_u01 ON &mw_prefix.category (cat_title);
215 CREATE INDEX &mw_prefix.category_i01 ON &mw_prefix.category (cat_pages);
217 CREATE SEQUENCE externallinks_el_id_seq;
218 CREATE TABLE &mw_prefix.externallinks (
219 el_id NUMBER NOT NULL,
220 el_from NUMBER NOT NULL,
221 el_to VARCHAR2(2048) NOT NULL,
222 el_index VARCHAR2(2048) NOT NULL
224 ALTER TABLE &mw_prefix.externallinks ADD CONSTRAINT &mw_prefix.externallinks_pk PRIMARY KEY (el_id);
225 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;
226 CREATE INDEX &mw_prefix.externallinks_i01 ON &mw_prefix.externallinks (el_from, el_to);
227 CREATE INDEX &mw_prefix.externallinks_i02 ON &mw_prefix.externallinks (el_to, el_from);
228 CREATE INDEX &mw_prefix.externallinks_i03 ON &mw_prefix.externallinks (el_index);
230 CREATE TABLE &mw_prefix.langlinks (
231 ll_from NUMBER NOT NULL,
232 ll_lang VARCHAR2(20),
233 ll_title VARCHAR2(255)
235 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;
236 CREATE UNIQUE INDEX &mw_prefix.langlinks_u01 ON &mw_prefix.langlinks (ll_from, ll_lang);
237 CREATE INDEX &mw_prefix.langlinks_i01 ON &mw_prefix.langlinks (ll_lang, ll_title);
239 CREATE TABLE &mw_prefix.iwlinks (
240 iwl_from NUMBER DEFAULT 0 NOT NULL,
241 iwl_prefix VARCHAR2(20),
242 iwl_title VARCHAR2(255)
244 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui01 ON &mw_prefix.iwlinks (iwl_from, iwl_prefix, iwl_title);
245 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui02 ON &mw_prefix.iwlinks (iwl_prefix, iwl_title, iwl_from);
247 CREATE TABLE &mw_prefix.site_stats (
248 ss_row_id NUMBER NOT NULL ,
249 ss_total_edits NUMBER DEFAULT 0,
250 ss_good_articles NUMBER DEFAULT 0,
251 ss_total_pages NUMBER DEFAULT -1,
252 ss_users NUMBER DEFAULT -1,
253 ss_active_users NUMBER DEFAULT -1,
254 ss_images NUMBER DEFAULT 0
256 CREATE UNIQUE INDEX &mw_prefix.site_stats_u01 ON &mw_prefix.site_stats (ss_row_id);
258 CREATE SEQUENCE ipblocks_ipb_id_seq;
259 CREATE TABLE &mw_prefix.ipblocks (
260 ipb_id NUMBER NOT NULL,
261 ipb_address VARCHAR2(255) NULL,
262 ipb_user NUMBER DEFAULT 0 NOT NULL,
263 ipb_by NUMBER DEFAULT 0 NOT NULL,
264 ipb_by_text VARCHAR2(255) NULL,
265 ipb_reason VARCHAR2(255) NOT NULL,
266 ipb_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
267 ipb_auto CHAR(1) DEFAULT '0' NOT NULL,
268 ipb_anon_only CHAR(1) DEFAULT '0' NOT NULL,
269 ipb_create_account CHAR(1) DEFAULT '1' NOT NULL,
270 ipb_enable_autoblock CHAR(1) DEFAULT '1' NOT NULL,
271 ipb_expiry TIMESTAMP(6) WITH TIME ZONE NOT NULL,
272 ipb_range_start VARCHAR2(255),
273 ipb_range_end VARCHAR2(255),
274 ipb_deleted CHAR(1) DEFAULT '0' NOT NULL,
275 ipb_block_email CHAR(1) DEFAULT '0' NOT NULL,
276 ipb_allow_usertalk CHAR(1) DEFAULT '0' NOT NULL,
277 ipb_parent_block_id NUMBER DEFAULT NULL
279 ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_pk PRIMARY KEY (ipb_id);
280 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;
281 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;
282 CREATE UNIQUE INDEX &mw_prefix.ipblocks_u01 ON &mw_prefix.ipblocks (ipb_address, ipb_user, ipb_auto, ipb_anon_only);
283 CREATE INDEX &mw_prefix.ipblocks_i01 ON &mw_prefix.ipblocks (ipb_user);
284 CREATE INDEX &mw_prefix.ipblocks_i02 ON &mw_prefix.ipblocks (ipb_range_start, ipb_range_end);
285 CREATE INDEX &mw_prefix.ipblocks_i03 ON &mw_prefix.ipblocks (ipb_timestamp);
286 CREATE INDEX &mw_prefix.ipblocks_i04 ON &mw_prefix.ipblocks (ipb_expiry);
287 CREATE INDEX &mw_prefix.ipblocks_i05 ON &mw_prefix.ipblocks (ipb_parent_block_id);
289 CREATE TABLE &mw_prefix.image (
290 img_name VARCHAR2(255) NOT NULL,
291 img_size NUMBER DEFAULT 0 NOT NULL,
292 img_width NUMBER DEFAULT 0 NOT NULL,
293 img_height NUMBER DEFAULT 0 NOT NULL,
295 img_bits NUMBER DEFAULT 0 NOT NULL,
296 img_media_type VARCHAR2(32),
297 img_major_mime VARCHAR2(32) DEFAULT 'unknown',
298 img_minor_mime VARCHAR2(100) DEFAULT 'unknown',
299 img_description VARCHAR2(255),
300 img_user NUMBER DEFAULT 0 NOT NULL,
301 img_user_text VARCHAR2(255) NOT NULL,
302 img_timestamp TIMESTAMP(6) WITH TIME ZONE,
303 img_sha1 VARCHAR2(32)
305 ALTER TABLE &mw_prefix.image ADD CONSTRAINT &mw_prefix.image_pk PRIMARY KEY (img_name);
306 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;
307 CREATE INDEX &mw_prefix.image_i01 ON &mw_prefix.image (img_user_text,img_timestamp);
308 CREATE INDEX &mw_prefix.image_i02 ON &mw_prefix.image (img_size);
309 CREATE INDEX &mw_prefix.image_i03 ON &mw_prefix.image (img_timestamp);
310 CREATE INDEX &mw_prefix.image_i04 ON &mw_prefix.image (img_sha1);
313 CREATE TABLE &mw_prefix.oldimage (
314 oi_name VARCHAR2(255) DEFAULT 0 NOT NULL,
315 oi_archive_name VARCHAR2(255),
316 oi_size NUMBER DEFAULT 0 NOT NULL,
317 oi_width NUMBER DEFAULT 0 NOT NULL,
318 oi_height NUMBER DEFAULT 0 NOT NULL,
319 oi_bits NUMBER DEFAULT 0 NOT NULL,
320 oi_description VARCHAR2(255),
321 oi_user NUMBER DEFAULT 0 NOT NULL,
322 oi_user_text VARCHAR2(255) NOT NULL,
323 oi_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
325 oi_media_type VARCHAR2(32) DEFAULT NULL,
326 oi_major_mime VARCHAR2(32) DEFAULT 'unknown',
327 oi_minor_mime VARCHAR2(100) DEFAULT 'unknown',
328 oi_deleted NUMBER DEFAULT 0 NOT NULL,
331 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;
332 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;
333 CREATE INDEX &mw_prefix.oldimage_i01 ON &mw_prefix.oldimage (oi_user_text,oi_timestamp);
334 CREATE INDEX &mw_prefix.oldimage_i02 ON &mw_prefix.oldimage (oi_name,oi_timestamp);
335 CREATE INDEX &mw_prefix.oldimage_i03 ON &mw_prefix.oldimage (oi_name,oi_archive_name);
336 CREATE INDEX &mw_prefix.oldimage_i04 ON &mw_prefix.oldimage (oi_sha1);
339 CREATE SEQUENCE filearchive_fa_id_seq;
340 CREATE TABLE &mw_prefix.filearchive (
341 fa_id NUMBER NOT NULL,
342 fa_name VARCHAR2(255) NOT NULL,
343 fa_archive_name VARCHAR2(255),
344 fa_storage_group VARCHAR2(16),
345 fa_storage_key VARCHAR2(64),
346 fa_deleted_user NUMBER DEFAULT 0 NOT NULL,
347 fa_deleted_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
348 fa_deleted_reason CLOB,
349 fa_size NUMBER DEFAULT 0 NOT NULL,
350 fa_width NUMBER DEFAULT 0 NOT NULL,
351 fa_height NUMBER DEFAULT 0 NOT NULL,
353 fa_bits NUMBER DEFAULT 0 NOT NULL,
354 fa_media_type VARCHAR2(32) DEFAULT NULL,
355 fa_major_mime VARCHAR2(32) DEFAULT 'unknown',
356 fa_minor_mime VARCHAR2(100) DEFAULT 'unknown',
357 fa_description VARCHAR2(255),
358 fa_user NUMBER DEFAULT 0 NOT NULL,
359 fa_user_text VARCHAR2(255) NOT NULL,
360 fa_timestamp TIMESTAMP(6) WITH TIME ZONE,
361 fa_deleted NUMBER DEFAULT 0 NOT NULL,
364 ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_pk PRIMARY KEY (fa_id);
365 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;
366 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;
367 CREATE INDEX &mw_prefix.filearchive_i01 ON &mw_prefix.filearchive (fa_name, fa_timestamp);
368 CREATE INDEX &mw_prefix.filearchive_i02 ON &mw_prefix.filearchive (fa_storage_group, fa_storage_key);
369 CREATE INDEX &mw_prefix.filearchive_i03 ON &mw_prefix.filearchive (fa_deleted_timestamp);
370 CREATE INDEX &mw_prefix.filearchive_i04 ON &mw_prefix.filearchive (fa_user_text,fa_timestamp);
371 CREATE INDEX &mw_prefix.filearchive_i05 ON &mw_prefix.filearchive (fa_sha1);
373 CREATE SEQUENCE uploadstash_us_id_seq;
374 CREATE TABLE &mw_prefix.uploadstash (
375 us_id NUMBER NOT NULL,
376 us_user NUMBER DEFAULT 0 NOT NULL,
377 us_key VARCHAR2(255) NOT NULL,
378 us_orig_path VARCHAR2(255) NOT NULL,
379 us_path VARCHAR2(255) NOT NULL,
380 us_source_type VARCHAR2(50),
381 us_timestamp TIMESTAMP(6) WITH TIME ZONE,
382 us_status VARCHAR2(50) NOT NULL,
384 us_size NUMBER NOT NULL,
385 us_sha1 VARCHAR2(32) NOT NULL,
386 us_mime VARCHAR2(255),
387 us_media_type VARCHAR2(32) DEFAULT NULL,
388 us_image_width NUMBER,
389 us_image_height NUMBER,
390 us_image_bits NUMBER,
393 ALTER TABLE &mw_prefix.uploadstash ADD CONSTRAINT &mw_prefix.uploadstash_pk PRIMARY KEY (us_id);
394 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;
395 CREATE INDEX &mw_prefix.uploadstash_i01 ON &mw_prefix.uploadstash (us_user);
396 CREATE INDEX &mw_prefix.uploadstash_i02 ON &mw_prefix.uploadstash (us_timestamp);
397 CREATE UNIQUE INDEX &mw_prefix.uploadstash_u01 ON &mw_prefix.uploadstash (us_key);
399 CREATE SEQUENCE recentchanges_rc_id_seq;
400 CREATE TABLE &mw_prefix.recentchanges (
401 rc_id NUMBER NOT NULL,
402 rc_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
403 rc_cur_time TIMESTAMP(6) WITH TIME ZONE,
404 rc_user NUMBER DEFAULT 0 NOT NULL,
405 rc_user_text VARCHAR2(255) NOT NULL,
406 rc_namespace NUMBER DEFAULT 0 NOT NULL,
407 rc_title VARCHAR2(255) NOT NULL,
408 rc_comment VARCHAR2(255),
409 rc_minor CHAR(1) DEFAULT '0' NOT NULL,
410 rc_bot CHAR(1) DEFAULT '0' NOT NULL,
411 rc_new CHAR(1) DEFAULT '0' NOT NULL,
412 rc_cur_id NUMBER DEFAULT 0 NOT NULL,
413 rc_this_oldid NUMBER DEFAULT 0 NOT NULL,
414 rc_last_oldid NUMBER DEFAULT 0 NOT NULL,
415 rc_type CHAR(1) DEFAULT '0' NOT NULL,
416 rc_source VARCHAR2(16),
417 rc_patrolled CHAR(1) DEFAULT '0' NOT NULL,
421 rc_deleted CHAR(1) DEFAULT '0' NOT NULL,
422 rc_logid NUMBER DEFAULT 0 NOT NULL,
423 rc_log_type VARCHAR2(255),
424 rc_log_action VARCHAR2(255),
427 ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_pk PRIMARY KEY (rc_id);
428 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;
429 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;
430 CREATE INDEX &mw_prefix.recentchanges_i01 ON &mw_prefix.recentchanges (rc_timestamp);
431 CREATE INDEX &mw_prefix.recentchanges_i02 ON &mw_prefix.recentchanges (rc_namespace, rc_title);
432 CREATE INDEX &mw_prefix.recentchanges_i03 ON &mw_prefix.recentchanges (rc_cur_id);
433 CREATE INDEX &mw_prefix.recentchanges_i04 ON &mw_prefix.recentchanges (rc_new,rc_namespace,rc_timestamp);
434 CREATE INDEX &mw_prefix.recentchanges_i05 ON &mw_prefix.recentchanges (rc_ip);
435 CREATE INDEX &mw_prefix.recentchanges_i06 ON &mw_prefix.recentchanges (rc_namespace, rc_user_text);
436 CREATE INDEX &mw_prefix.recentchanges_i07 ON &mw_prefix.recentchanges (rc_user_text, rc_timestamp);
438 CREATE TABLE &mw_prefix.watchlist (
439 wl_user NUMBER NOT NULL,
440 wl_namespace NUMBER DEFAULT 0 NOT NULL,
441 wl_title VARCHAR2(255) NOT NULL,
442 wl_notificationtimestamp TIMESTAMP(6) WITH TIME ZONE
444 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;
445 CREATE UNIQUE INDEX &mw_prefix.watchlist_u01 ON &mw_prefix.watchlist (wl_user, wl_namespace, wl_title);
446 CREATE INDEX &mw_prefix.watchlist_i01 ON &mw_prefix.watchlist (wl_namespace, wl_title);
449 CREATE TABLE &mw_prefix.searchindex (
450 si_page NUMBER NOT NULL,
451 si_title VARCHAR2(255),
452 si_text CLOB NOT NULL
454 CREATE UNIQUE INDEX &mw_prefix.searchindex_u01 ON &mw_prefix.searchindex (si_page);
456 CREATE TABLE &mw_prefix.interwiki (
457 iw_prefix VARCHAR2(32) NOT NULL,
458 iw_url VARCHAR2(127) NOT NULL,
459 iw_api BLOB NOT NULL,
460 iw_wikiid VARCHAR2(64),
461 iw_local CHAR(1) NOT NULL,
462 iw_trans CHAR(1) DEFAULT '0' NOT NULL
464 CREATE UNIQUE INDEX &mw_prefix.interwiki_u01 ON &mw_prefix.interwiki (iw_prefix);
466 CREATE TABLE &mw_prefix.querycache (
467 qc_type VARCHAR2(32) NOT NULL,
468 qc_value NUMBER DEFAULT 0 NOT NULL,
469 qc_namespace NUMBER DEFAULT 0 NOT NULL,
470 qc_title VARCHAR2(255) NOT NULL
472 CREATE INDEX &mw_prefix.querycache_u01 ON &mw_prefix.querycache (qc_type,qc_value);
474 CREATE TABLE &mw_prefix.objectcache (
475 keyname VARCHAR2(255) ,
477 exptime TIMESTAMP(6) WITH TIME ZONE NOT NULL
479 CREATE INDEX &mw_prefix.objectcache_i01 ON &mw_prefix.objectcache (exptime);
481 CREATE TABLE &mw_prefix.transcache (
482 tc_url VARCHAR2(255) NOT NULL,
483 tc_contents CLOB NOT NULL,
484 tc_time TIMESTAMP(6) WITH TIME ZONE NOT NULL
486 CREATE UNIQUE INDEX &mw_prefix.transcache_u01 ON &mw_prefix.transcache (tc_url);
489 CREATE SEQUENCE logging_log_id_seq;
490 CREATE TABLE &mw_prefix.logging (
491 log_id NUMBER NOT NULL,
492 log_type VARCHAR2(10) NOT NULL,
493 log_action VARCHAR2(10) NOT NULL,
494 log_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
495 log_user NUMBER DEFAULT 0 NOT NULL,
496 log_user_text VARCHAR2(255),
497 log_namespace NUMBER DEFAULT 0 NOT NULL,
498 log_title VARCHAR2(255) NOT NULL,
500 log_comment VARCHAR2(255),
502 log_deleted CHAR(1) DEFAULT '0' NOT NULL
504 ALTER TABLE &mw_prefix.logging ADD CONSTRAINT &mw_prefix.logging_pk PRIMARY KEY (log_id);
505 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;
506 CREATE INDEX &mw_prefix.logging_i01 ON &mw_prefix.logging (log_type, log_timestamp);
507 CREATE INDEX &mw_prefix.logging_i02 ON &mw_prefix.logging (log_user, log_timestamp);
508 CREATE INDEX &mw_prefix.logging_i03 ON &mw_prefix.logging (log_namespace, log_title, log_timestamp);
509 CREATE INDEX &mw_prefix.logging_i04 ON &mw_prefix.logging (log_timestamp);
510 CREATE INDEX &mw_prefix.logging_i05 ON &mw_prefix.logging (log_type, log_action, log_timestamp);
511 CREATE INDEX &mw_prefix.logging_i06 ON &mw_prefix.logging (log_user_text, log_type, log_timestamp);
512 CREATE INDEX &mw_prefix.logging_i07 ON &mw_prefix.logging (log_user_text, log_timestamp);
514 CREATE TABLE &mw_prefix.log_search (
515 ls_field VARCHAR2(32) NOT NULL,
516 ls_value VARCHAR2(255) NOT NULL,
517 ls_log_id NuMBER DEFAULT 0 NOT NULL
519 ALTER TABLE &mw_prefix.log_search ADD CONSTRAINT log_search_pk PRIMARY KEY (ls_field,ls_value,ls_log_id);
520 CREATE INDEX &mw_prefix.log_search_i01 ON &mw_prefix.log_search (ls_log_id);
523 CREATE SEQUENCE job_job_id_seq;
524 CREATE TABLE &mw_prefix.job (
525 job_id NUMBER NOT NULL,
526 job_cmd VARCHAR2(60) NOT NULL,
527 job_namespace NUMBER DEFAULT 0 NOT NULL,
528 job_title VARCHAR2(255) NOT NULL,
529 job_timestamp TIMESTAMP(6) WITH TIME ZONE NULL,
530 job_params CLOB NOT NULL,
531 job_random NUMBER DEFAULT 0 NOT NULL,
532 job_token VARCHAR2(32),
533 job_token_timestamp TIMESTAMP(6) WITH TIME ZONE,
534 job_sha1 VARCHAR2(32),
535 job_attempts NUMBER DEFAULT 0 NOT NULL
537 ALTER TABLE &mw_prefix.job ADD CONSTRAINT &mw_prefix.job_pk PRIMARY KEY (job_id);
538 CREATE INDEX &mw_prefix.job_i01 ON &mw_prefix.job (job_cmd, job_namespace, job_title);
539 CREATE INDEX &mw_prefix.job_i02 ON &mw_prefix.job (job_timestamp);
540 CREATE INDEX &mw_prefix.job_i03 ON &mw_prefix.job (job_sha1);
541 CREATE INDEX &mw_prefix.job_i04 ON &mw_prefix.job (job_cmd,job_token,job_random);
542 CREATE INDEX &mw_prefix.job_i05 ON &mw_prefix.job (job_attempts);
544 CREATE TABLE &mw_prefix.querycache_info (
545 qci_type VARCHAR2(32) NOT NULL,
546 qci_timestamp TIMESTAMP(6) WITH TIME ZONE NULL
548 CREATE UNIQUE INDEX &mw_prefix.querycache_info_u01 ON &mw_prefix.querycache_info (qci_type);
550 CREATE TABLE &mw_prefix.redirect (
551 rd_from NUMBER NOT NULL,
552 rd_namespace NUMBER DEFAULT 0 NOT NULL,
553 rd_title VARCHAR2(255) NOT NULL,
554 rd_interwiki VARCHAR2(32),
555 rd_fragment VARCHAR2(255)
557 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;
558 CREATE INDEX &mw_prefix.redirect_i01 ON &mw_prefix.redirect (rd_namespace,rd_title,rd_from);
560 CREATE TABLE &mw_prefix.querycachetwo (
561 qcc_type VARCHAR2(32) NOT NULL,
562 qcc_value NUMBER DEFAULT 0 NOT NULL,
563 qcc_namespace NUMBER DEFAULT 0 NOT NULL,
564 qcc_title VARCHAR2(255),
565 qcc_namespacetwo NUMBER DEFAULT 0 NOT NULL,
566 qcc_titletwo VARCHAR2(255)
568 CREATE INDEX &mw_prefix.querycachetwo_i01 ON &mw_prefix.querycachetwo (qcc_type,qcc_value);
569 CREATE INDEX &mw_prefix.querycachetwo_i02 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespace,qcc_title);
570 CREATE INDEX &mw_prefix.querycachetwo_i03 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
572 CREATE SEQUENCE page_restrictions_pr_id_seq;
573 CREATE TABLE &mw_prefix.page_restrictions (
574 pr_id NUMBER NOT NULL,
575 pr_page NUMBER NOT NULL,
576 pr_type VARCHAR2(255) NOT NULL,
577 pr_level VARCHAR2(255) NOT NULL,
578 pr_cascade NUMBER NOT NULL,
580 pr_expiry TIMESTAMP(6) WITH TIME ZONE NULL
582 ALTER TABLE &mw_prefix.page_restrictions ADD CONSTRAINT &mw_prefix.page_restrictions_pk PRIMARY KEY (pr_id);
583 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;
584 CREATE UNIQUE INDEX &mw_prefix.page_restrictions_u01 ON &mw_prefix.page_restrictions (pr_page,pr_type);
585 CREATE INDEX &mw_prefix.page_restrictions_i01 ON &mw_prefix.page_restrictions (pr_type,pr_level);
586 CREATE INDEX &mw_prefix.page_restrictions_i02 ON &mw_prefix.page_restrictions (pr_level);
587 CREATE INDEX &mw_prefix.page_restrictions_i03 ON &mw_prefix.page_restrictions (pr_cascade);
589 CREATE TABLE &mw_prefix.protected_titles (
590 pt_namespace NUMBER DEFAULT 0 NOT NULL,
591 pt_title VARCHAR2(255) NOT NULL,
592 pt_user NUMBER NOT NULL,
593 pt_reason VARCHAR2(255),
594 pt_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
595 pt_expiry VARCHAR2(14) NOT NULL,
596 pt_create_perm VARCHAR2(60) NOT NULL
598 CREATE UNIQUE INDEX &mw_prefix.protected_titles_u01 ON &mw_prefix.protected_titles (pt_namespace,pt_title);
599 CREATE INDEX &mw_prefix.protected_titles_i01 ON &mw_prefix.protected_titles (pt_timestamp);
601 CREATE TABLE &mw_prefix.page_props (
602 pp_page NUMBER NOT NULL,
603 pp_propname VARCHAR2(60) NOT NULL,
604 pp_value BLOB NOT NULL
606 CREATE UNIQUE INDEX &mw_prefix.page_props_u01 ON &mw_prefix.page_props (pp_page,pp_propname);
609 CREATE TABLE &mw_prefix.updatelog (
610 ul_key VARCHAR2(255) NOT NULL,
613 ALTER TABLE &mw_prefix.updatelog ADD CONSTRAINT &mw_prefix.updatelog_pk PRIMARY KEY (ul_key);
615 CREATE TABLE &mw_prefix.change_tag (
616 ct_rc_id NUMBER NULL,
617 ct_log_id NUMBER NULL,
618 ct_rev_id NUMBER NULL,
619 ct_tag VARCHAR2(255) NOT NULL,
622 CREATE UNIQUE INDEX &mw_prefix.change_tag_u01 ON &mw_prefix.change_tag (ct_rc_id,ct_tag);
623 CREATE UNIQUE INDEX &mw_prefix.change_tag_u02 ON &mw_prefix.change_tag (ct_log_id,ct_tag);
624 CREATE UNIQUE INDEX &mw_prefix.change_tag_u03 ON &mw_prefix.change_tag (ct_rev_id,ct_tag);
625 CREATE INDEX &mw_prefix.change_tag_i01 ON &mw_prefix.change_tag (ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
627 CREATE TABLE &mw_prefix.tag_summary (
628 ts_rc_id NUMBER NULL,
629 ts_log_id NUMBER NULL,
630 ts_rev_id NUMBER NULL,
631 ts_tags BLOB NOT NULL
633 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u01 ON &mw_prefix.tag_summary (ts_rc_id);
634 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u02 ON &mw_prefix.tag_summary (ts_log_id);
635 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u03 ON &mw_prefix.tag_summary (ts_rev_id);
637 CREATE TABLE &mw_prefix.valid_tag (
638 vt_tag VARCHAR2(255) NOT NULL
640 ALTER TABLE &mw_prefix.valid_tag ADD CONSTRAINT &mw_prefix.valid_tag_pk PRIMARY KEY (vt_tag);
642 -- This table is not used unless profiling is turned on
643 --CREATE TABLE &mw_prefix.profiling (
644 -- pf_count NUMBER DEFAULT 0 NOT NULL,
645 -- pf_time NUMBER(18,10) DEFAULT 0 NOT NULL,
646 -- pf_memory NUMBER(18,10) DEFAULT 0 NOT NULL,
647 -- pf_name VARCHAR2(255),
648 -- pf_server VARCHAR2(30)
650 --CREATE UNIQUE INDEX &mw_prefix.profiling_u01 ON &mw_prefix.profiling (pf_name, pf_server);
652 CREATE INDEX &mw_prefix.si_title_idx ON &mw_prefix.searchindex(si_title) INDEXTYPE IS ctxsys.context;
653 CREATE INDEX &mw_prefix.si_text_idx ON &mw_prefix.searchindex(si_text) INDEXTYPE IS ctxsys.context;
655 CREATE TABLE &mw_prefix.l10n_cache (
656 lc_lang varchar2(32) NOT NULL,
657 lc_key varchar2(255) NOT NULL,
658 lc_value clob NOT NULL
660 CREATE INDEX &mw_prefix.l10n_cache_u01 ON &mw_prefix.l10n_cache (lc_lang, lc_key);
662 CREATE TABLE &mw_prefix.module_deps (
663 md_module VARCHAR2(255) NOT NULL,
664 md_skin VARCHAR2(32) NOT NULL,
665 md_deps BLOB NOT NULL
667 CREATE UNIQUE INDEX &mw_prefix.module_deps_u01 ON &mw_prefix.module_deps (md_module, md_skin);
669 CREATE SEQUENCE sites_site_id_seq MINVALUE 0 START WITH 0;
670 CREATE TABLE &mw_prefix.sites (
671 site_id NUMBER NOT NULL,
672 site_global_key VARCHAR2(32) NOT NULL,
673 site_type VARCHAR2(32) NOT NULL,
674 site_group VARCHAR2(32) NOT NULL,
675 site_source VARCHAR2(32) NOT NULL,
676 site_language VARCHAR2(32) NOT NULL,
677 site_protocol VARCHAR2(32) NOT NULL,
678 site_domain VARCHAR2(255) NOT NULL,
679 site_data BLOB NOT NULL,
680 site_forward NUMBER(1) NOT NULL,
681 site_config BLOB NOT NULL
683 ALTER TABLE &mw_prefix.sites ADD CONSTRAINT &mw_prefix.sites_pk PRIMARY KEY (site_id);
684 CREATE UNIQUE INDEX &mw_prefix.sites_u01 ON &mw_prefix.sites (site_global_key);
685 CREATE INDEX &mw_prefix.sites_i01 ON &mw_prefix.sites (site_type);
686 CREATE INDEX &mw_prefix.sites_i02 ON &mw_prefix.sites (site_group);
687 CREATE INDEX &mw_prefix.sites_i03 ON &mw_prefix.sites (site_source);
688 CREATE INDEX &mw_prefix.sites_i04 ON &mw_prefix.sites (site_language);
689 CREATE INDEX &mw_prefix.sites_i05 ON &mw_prefix.sites (site_protocol);
690 CREATE INDEX &mw_prefix.sites_i06 ON &mw_prefix.sites (site_domain);
691 CREATE INDEX &mw_prefix.sites_i07 ON &mw_prefix.sites (site_forward);
693 CREATE TABLE &mw_prefix.site_identifiers (
694 si_site NUMBER NOT NULL,
695 si_type VARCHAR2(32) NOT NULL,
696 si_key VARCHAR2(32) NOT NULL
698 CREATE UNIQUE INDEX &mw_prefix.site_identifiers_u01 ON &mw_prefix.site_identifiers (si_type, si_key);
699 CREATE INDEX &mw_prefix.site_identifiers_i01 ON &mw_prefix.site_identifiers (si_site);
700 CREATE INDEX &mw_prefix.site_identifiers_i02 ON &mw_prefix.site_identifiers (si_key);
702 -- do not prefix this table as it breaks parserTests
703 CREATE TABLE wiki_field_info_full (
704 table_name VARCHAR2(35) NOT NULL,
705 column_name VARCHAR2(35) NOT NULL,
706 data_default VARCHAR2(4000),
707 data_length NUMBER NOT NULL,
708 data_type VARCHAR2(106),
709 not_null CHAR(1) NOT NULL,
714 ALTER TABLE wiki_field_info_full ADD CONSTRAINT wiki_field_info_full_pk PRIMARY KEY (table_name, column_name);
717 CREATE PROCEDURE fill_wiki_info IS
719 DELETE wiki_field_info_full;
721 FOR x_rec IN (SELECT t.table_name table_name, t.column_name,
722 t.data_default, t.data_length, t.data_type,
723 DECODE (t.nullable, 'Y', '1', 'N', '0') not_null,
725 FROM user_cons_columns ucc,
727 WHERE ucc.table_name = t.table_name
728 AND ucc.column_name = t.column_name
729 AND uc.constraint_name = ucc.constraint_name
730 AND uc.constraint_type = 'P'
731 AND ROWNUM < 2) prim,
733 FROM user_ind_columns uic,
735 WHERE uic.table_name = t.table_name
736 AND uic.column_name = t.column_name
737 AND ui.index_name = uic.index_name
738 AND ui.uniqueness = 'UNIQUE'
739 AND ROWNUM < 2) uniq,
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 = 'NONUNIQUE'
747 AND ROWNUM < 2) nonuniq
748 FROM user_tab_columns t, user_tables ut
749 WHERE ut.table_name = t.table_name)
751 INSERT INTO wiki_field_info_full
752 (table_name, column_name,
753 data_default, data_length,
754 data_type, not_null, prim,
757 VALUES (x_rec.table_name, x_rec.column_name,
758 x_rec.data_default, x_rec.data_length,
759 x_rec.data_type, x_rec.not_null, x_rec.prim,
760 x_rec.uniq, x_rec.nonuniq
768 CREATE OR REPLACE PROCEDURE duplicate_table(p_tabname IN VARCHAR2,
769 p_oldprefix IN VARCHAR2,
770 p_newprefix IN VARCHAR2,
771 p_temporary IN BOOLEAN) IS
772 e_table_not_exist EXCEPTION;
773 PRAGMA EXCEPTION_INIT(e_table_not_exist, -00942);
774 l_temp_ei_sql VARCHAR2(2000);
775 l_temporary BOOLEAN := p_temporary;
778 EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname ||
779 ' CASCADE CONSTRAINTS PURGE';
781 WHEN e_table_not_exist THEN
784 IF (p_tabname = 'SEARCHINDEX') THEN
785 l_temporary := FALSE;
787 IF (l_temporary) THEN
788 EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix ||
790 ' ON COMMIT PRESERVE ROWS AS SELECT * FROM ' ||
791 p_oldprefix || p_tabname || ' WHERE ROWNUM = 0';
793 EXECUTE IMMEDIATE 'CREATE TABLE ' || p_newprefix || p_tabname ||
794 ' AS SELECT * FROM ' || p_oldprefix || p_tabname ||
797 FOR rc IN (SELECT column_name, data_default
798 FROM user_tab_columns
799 WHERE table_name = p_oldprefix || p_tabname
800 AND data_default IS NOT NULL) LOOP
801 EXECUTE IMMEDIATE 'ALTER TABLE ' || p_newprefix || p_tabname ||
802 ' MODIFY ' || rc.column_name || ' DEFAULT ' ||
803 SUBSTR(rc.data_default, 1, 2000);
805 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('CONSTRAINT',
809 USER || '"."' || p_oldprefix,
810 USER || '"."' || p_newprefix),
811 '"' || constraint_name || '"',
812 '"' || p_newprefix || constraint_name || '"') DDLVC2,
814 FROM user_constraints uc
815 WHERE table_name = p_oldprefix || p_tabname
816 AND constraint_type = 'P') LOOP
817 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
818 l_temp_ei_sql := SUBSTR(l_temp_ei_sql,
822 INSTR(l_temp_ei_sql, 'PRIMARY KEY') + 1) + 1);
823 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
824 EXECUTE IMMEDIATE l_temp_ei_sql;
827 IF (NOT l_temporary) THEN
828 FOR rc IN (SELECT REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('REF_CONSTRAINT',
832 USER || '"."' || p_oldprefix,
833 USER || '"."' || p_newprefix) DDLVC2,
835 FROM user_constraints uc
836 WHERE table_name = p_oldprefix || p_tabname
837 AND constraint_type = 'R') LOOP
838 IF nvl(length(l_temp_ei_sql), 0) > 0 AND
839 INSTR(l_temp_ei_sql, 'PRIMARY KEY') = 0 THEN
840 EXECUTE IMMEDIATE l_temp_ei_sql;
844 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
848 USER || '"."' || p_oldprefix,
849 USER || '"."' || p_newprefix),
850 '"' || index_name || '"',
851 '"' || p_newprefix || index_name || '"') DDLVC2,
855 WHERE table_name = p_oldprefix || p_tabname
856 AND index_type NOT IN ('LOB', 'DOMAIN')
859 FROM user_constraints
860 WHERE table_name = ui.table_name
861 AND constraint_name = ui.index_name)) LOOP
862 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
863 l_temp_ei_sql := SUBSTR(l_temp_ei_sql,
868 '"' || USER || '"."' || p_newprefix || '"') + 1) + 1);
869 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
870 EXECUTE IMMEDIATE l_temp_ei_sql;
873 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
877 USER || '"."' || p_oldprefix,
878 USER || '"."' || p_newprefix),
879 '"' || index_name || '"',
880 '"' || p_newprefix || index_name || '"') DDLVC2,
884 WHERE table_name = p_oldprefix || p_tabname
885 AND index_type = 'DOMAIN'
888 FROM user_constraints
889 WHERE table_name = ui.table_name
890 AND constraint_name = ui.index_name)) LOOP
891 l_temp_ei_sql := rc.ddlvc2;
892 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
893 EXECUTE IMMEDIATE l_temp_ei_sql;
896 FOR rc IN (SELECT REPLACE(REPLACE(UPPER(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('TRIGGER',
900 USER || '"."' || p_oldprefix,
901 USER || '"."' || p_newprefix),
902 ' ON ' || p_oldprefix || p_tabname,
903 ' ON ' || p_newprefix || p_tabname) DDLVC2,
906 WHERE table_name = p_oldprefix || p_tabname) LOOP
907 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'ALTER ') - 1);
908 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
909 EXECUTE IMMEDIATE l_temp_ei_sql;
917 CREATE OR REPLACE FUNCTION BITOR (x IN NUMBER, y IN NUMBER) RETURN NUMBER AS
919 RETURN (x + y - BITAND(x, y));
924 CREATE OR REPLACE FUNCTION BITNOT (x IN NUMBER) RETURN NUMBER AS
926 RETURN (4294967295 - x);
930 CREATE OR REPLACE TYPE GET_OUTPUT_TYPE IS TABLE OF VARCHAR2(255);
933 CREATE OR REPLACE FUNCTION GET_OUTPUT_LINES RETURN GET_OUTPUT_TYPE PIPELINED AS
934 v_line VARCHAR2(255);
935 v_status INTEGER := 0;
939 DBMS_OUTPUT.GET_LINE(v_line, v_status);
940 IF (v_status = 0) THEN RETURN; END IF;
951 CREATE OR REPLACE FUNCTION GET_SEQUENCE_VALUE(seq IN VARCHAR2) RETURN NUMBER AS
954 EXECUTE IMMEDIATE 'SELECT '||seq||'.NEXTVAL INTO :outVar FROM DUAL' INTO v_value;