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);
437 CREATE INDEX &mw_prefix.recentchanges_i08 ON &mw_prefix.recentchanges (rc_namespace, rc_type, rc_patrolled, rc_timestamp);
439 CREATE TABLE &mw_prefix.watchlist (
440 wl_id NUMBER NOT NULL,
441 wl_user NUMBER NOT NULL,
442 wl_namespace NUMBER DEFAULT 0 NOT NULL,
443 wl_title VARCHAR2(255) NOT NULL,
444 wl_notificationtimestamp TIMESTAMP(6) WITH TIME ZONE
446 ALTER TABLE &mw_prefix.watchlist ADD CONSTRAINT &mw_prefix.watchlist_pk PRIMARY KEY (wl_id);
447 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;
448 CREATE UNIQUE INDEX &mw_prefix.watchlist_u01 ON &mw_prefix.watchlist (wl_user, wl_namespace, wl_title);
449 CREATE INDEX &mw_prefix.watchlist_i01 ON &mw_prefix.watchlist (wl_namespace, wl_title);
452 CREATE TABLE &mw_prefix.searchindex (
453 si_page NUMBER NOT NULL,
454 si_title VARCHAR2(255),
455 si_text CLOB NOT NULL
457 CREATE UNIQUE INDEX &mw_prefix.searchindex_u01 ON &mw_prefix.searchindex (si_page);
459 CREATE TABLE &mw_prefix.interwiki (
460 iw_prefix VARCHAR2(32) NOT NULL,
461 iw_url VARCHAR2(127) NOT NULL,
462 iw_api BLOB NOT NULL,
463 iw_wikiid VARCHAR2(64),
464 iw_local CHAR(1) NOT NULL,
465 iw_trans CHAR(1) DEFAULT '0' NOT NULL
467 CREATE UNIQUE INDEX &mw_prefix.interwiki_u01 ON &mw_prefix.interwiki (iw_prefix);
469 CREATE TABLE &mw_prefix.querycache (
470 qc_type VARCHAR2(32) NOT NULL,
471 qc_value NUMBER DEFAULT 0 NOT NULL,
472 qc_namespace NUMBER DEFAULT 0 NOT NULL,
473 qc_title VARCHAR2(255) NOT NULL
475 CREATE INDEX &mw_prefix.querycache_u01 ON &mw_prefix.querycache (qc_type,qc_value);
477 CREATE TABLE &mw_prefix.objectcache (
478 keyname VARCHAR2(255) ,
480 exptime TIMESTAMP(6) WITH TIME ZONE NOT NULL
482 CREATE INDEX &mw_prefix.objectcache_i01 ON &mw_prefix.objectcache (exptime);
484 CREATE TABLE &mw_prefix.transcache (
485 tc_url VARCHAR2(255) NOT NULL,
486 tc_contents CLOB NOT NULL,
487 tc_time TIMESTAMP(6) WITH TIME ZONE NOT NULL
489 CREATE UNIQUE INDEX &mw_prefix.transcache_u01 ON &mw_prefix.transcache (tc_url);
492 CREATE SEQUENCE logging_log_id_seq;
493 CREATE TABLE &mw_prefix.logging (
494 log_id NUMBER NOT NULL,
495 log_type VARCHAR2(10) NOT NULL,
496 log_action VARCHAR2(10) NOT NULL,
497 log_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
498 log_user NUMBER DEFAULT 0 NOT NULL,
499 log_user_text VARCHAR2(255),
500 log_namespace NUMBER DEFAULT 0 NOT NULL,
501 log_title VARCHAR2(255) NOT NULL,
503 log_comment VARCHAR2(255),
505 log_deleted CHAR(1) DEFAULT '0' NOT NULL
507 ALTER TABLE &mw_prefix.logging ADD CONSTRAINT &mw_prefix.logging_pk PRIMARY KEY (log_id);
508 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;
509 CREATE INDEX &mw_prefix.logging_i01 ON &mw_prefix.logging (log_type, log_timestamp);
510 CREATE INDEX &mw_prefix.logging_i02 ON &mw_prefix.logging (log_user, log_timestamp);
511 CREATE INDEX &mw_prefix.logging_i03 ON &mw_prefix.logging (log_namespace, log_title, log_timestamp);
512 CREATE INDEX &mw_prefix.logging_i04 ON &mw_prefix.logging (log_timestamp);
513 CREATE INDEX &mw_prefix.logging_i05 ON &mw_prefix.logging (log_type, log_action, log_timestamp);
514 CREATE INDEX &mw_prefix.logging_i06 ON &mw_prefix.logging (log_user_text, log_type, log_timestamp);
515 CREATE INDEX &mw_prefix.logging_i07 ON &mw_prefix.logging (log_user_text, log_timestamp);
517 CREATE TABLE &mw_prefix.log_search (
518 ls_field VARCHAR2(32) NOT NULL,
519 ls_value VARCHAR2(255) NOT NULL,
520 ls_log_id NuMBER DEFAULT 0 NOT NULL
522 ALTER TABLE &mw_prefix.log_search ADD CONSTRAINT log_search_pk PRIMARY KEY (ls_field,ls_value,ls_log_id);
523 CREATE INDEX &mw_prefix.log_search_i01 ON &mw_prefix.log_search (ls_log_id);
526 CREATE SEQUENCE job_job_id_seq;
527 CREATE TABLE &mw_prefix.job (
528 job_id NUMBER NOT NULL,
529 job_cmd VARCHAR2(60) NOT NULL,
530 job_namespace NUMBER DEFAULT 0 NOT NULL,
531 job_title VARCHAR2(255) NOT NULL,
532 job_timestamp TIMESTAMP(6) WITH TIME ZONE NULL,
533 job_params CLOB NOT NULL,
534 job_random NUMBER DEFAULT 0 NOT NULL,
535 job_token VARCHAR2(32),
536 job_token_timestamp TIMESTAMP(6) WITH TIME ZONE,
537 job_sha1 VARCHAR2(32),
538 job_attempts NUMBER DEFAULT 0 NOT NULL
540 ALTER TABLE &mw_prefix.job ADD CONSTRAINT &mw_prefix.job_pk PRIMARY KEY (job_id);
541 CREATE INDEX &mw_prefix.job_i01 ON &mw_prefix.job (job_cmd, job_namespace, job_title);
542 CREATE INDEX &mw_prefix.job_i02 ON &mw_prefix.job (job_timestamp);
543 CREATE INDEX &mw_prefix.job_i03 ON &mw_prefix.job (job_sha1);
544 CREATE INDEX &mw_prefix.job_i04 ON &mw_prefix.job (job_cmd,job_token,job_random);
545 CREATE INDEX &mw_prefix.job_i05 ON &mw_prefix.job (job_attempts);
547 CREATE TABLE &mw_prefix.querycache_info (
548 qci_type VARCHAR2(32) NOT NULL,
549 qci_timestamp TIMESTAMP(6) WITH TIME ZONE NULL
551 CREATE UNIQUE INDEX &mw_prefix.querycache_info_u01 ON &mw_prefix.querycache_info (qci_type);
553 CREATE TABLE &mw_prefix.redirect (
554 rd_from NUMBER NOT NULL,
555 rd_namespace NUMBER DEFAULT 0 NOT NULL,
556 rd_title VARCHAR2(255) NOT NULL,
557 rd_interwiki VARCHAR2(32),
558 rd_fragment VARCHAR2(255)
560 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;
561 CREATE INDEX &mw_prefix.redirect_i01 ON &mw_prefix.redirect (rd_namespace,rd_title,rd_from);
563 CREATE TABLE &mw_prefix.querycachetwo (
564 qcc_type VARCHAR2(32) NOT NULL,
565 qcc_value NUMBER DEFAULT 0 NOT NULL,
566 qcc_namespace NUMBER DEFAULT 0 NOT NULL,
567 qcc_title VARCHAR2(255),
568 qcc_namespacetwo NUMBER DEFAULT 0 NOT NULL,
569 qcc_titletwo VARCHAR2(255)
571 CREATE INDEX &mw_prefix.querycachetwo_i01 ON &mw_prefix.querycachetwo (qcc_type,qcc_value);
572 CREATE INDEX &mw_prefix.querycachetwo_i02 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespace,qcc_title);
573 CREATE INDEX &mw_prefix.querycachetwo_i03 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
575 CREATE SEQUENCE page_restrictions_pr_id_seq;
576 CREATE TABLE &mw_prefix.page_restrictions (
577 pr_id NUMBER NOT NULL,
578 pr_page NUMBER NOT NULL,
579 pr_type VARCHAR2(255) NOT NULL,
580 pr_level VARCHAR2(255) NOT NULL,
581 pr_cascade NUMBER NOT NULL,
583 pr_expiry TIMESTAMP(6) WITH TIME ZONE NULL
585 ALTER TABLE &mw_prefix.page_restrictions ADD CONSTRAINT &mw_prefix.page_restrictions_pk PRIMARY KEY (pr_id);
586 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;
587 CREATE UNIQUE INDEX &mw_prefix.page_restrictions_u01 ON &mw_prefix.page_restrictions (pr_page,pr_type);
588 CREATE INDEX &mw_prefix.page_restrictions_i01 ON &mw_prefix.page_restrictions (pr_type,pr_level);
589 CREATE INDEX &mw_prefix.page_restrictions_i02 ON &mw_prefix.page_restrictions (pr_level);
590 CREATE INDEX &mw_prefix.page_restrictions_i03 ON &mw_prefix.page_restrictions (pr_cascade);
592 CREATE TABLE &mw_prefix.protected_titles (
593 pt_namespace NUMBER DEFAULT 0 NOT NULL,
594 pt_title VARCHAR2(255) NOT NULL,
595 pt_user NUMBER NOT NULL,
596 pt_reason VARCHAR2(255),
597 pt_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
598 pt_expiry VARCHAR2(14) NOT NULL,
599 pt_create_perm VARCHAR2(60) NOT NULL
601 CREATE UNIQUE INDEX &mw_prefix.protected_titles_u01 ON &mw_prefix.protected_titles (pt_namespace,pt_title);
602 CREATE INDEX &mw_prefix.protected_titles_i01 ON &mw_prefix.protected_titles (pt_timestamp);
604 CREATE TABLE &mw_prefix.page_props (
605 pp_page NUMBER NOT NULL,
606 pp_propname VARCHAR2(60) NOT NULL,
607 pp_value BLOB NOT NULL
609 CREATE UNIQUE INDEX &mw_prefix.page_props_u01 ON &mw_prefix.page_props (pp_page,pp_propname);
612 CREATE TABLE &mw_prefix.updatelog (
613 ul_key VARCHAR2(255) NOT NULL,
616 ALTER TABLE &mw_prefix.updatelog ADD CONSTRAINT &mw_prefix.updatelog_pk PRIMARY KEY (ul_key);
618 CREATE TABLE &mw_prefix.change_tag (
619 ct_rc_id NUMBER NULL,
620 ct_log_id NUMBER NULL,
621 ct_rev_id NUMBER NULL,
622 ct_tag VARCHAR2(255) NOT NULL,
625 CREATE UNIQUE INDEX &mw_prefix.change_tag_u01 ON &mw_prefix.change_tag (ct_rc_id,ct_tag);
626 CREATE UNIQUE INDEX &mw_prefix.change_tag_u02 ON &mw_prefix.change_tag (ct_log_id,ct_tag);
627 CREATE UNIQUE INDEX &mw_prefix.change_tag_u03 ON &mw_prefix.change_tag (ct_rev_id,ct_tag);
628 CREATE INDEX &mw_prefix.change_tag_i01 ON &mw_prefix.change_tag (ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
630 CREATE TABLE &mw_prefix.tag_summary (
631 ts_rc_id NUMBER NULL,
632 ts_log_id NUMBER NULL,
633 ts_rev_id NUMBER NULL,
634 ts_tags BLOB NOT NULL
636 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u01 ON &mw_prefix.tag_summary (ts_rc_id);
637 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u02 ON &mw_prefix.tag_summary (ts_log_id);
638 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u03 ON &mw_prefix.tag_summary (ts_rev_id);
640 CREATE TABLE &mw_prefix.valid_tag (
641 vt_tag VARCHAR2(255) NOT NULL
643 ALTER TABLE &mw_prefix.valid_tag ADD CONSTRAINT &mw_prefix.valid_tag_pk PRIMARY KEY (vt_tag);
645 -- This table is not used unless profiling is turned on
646 --CREATE TABLE &mw_prefix.profiling (
647 -- pf_count NUMBER DEFAULT 0 NOT NULL,
648 -- pf_time NUMBER(18,10) DEFAULT 0 NOT NULL,
649 -- pf_memory NUMBER(18,10) DEFAULT 0 NOT NULL,
650 -- pf_name VARCHAR2(255),
651 -- pf_server VARCHAR2(30)
653 --CREATE UNIQUE INDEX &mw_prefix.profiling_u01 ON &mw_prefix.profiling (pf_name, pf_server);
655 CREATE INDEX &mw_prefix.si_title_idx ON &mw_prefix.searchindex(si_title) INDEXTYPE IS ctxsys.context;
656 CREATE INDEX &mw_prefix.si_text_idx ON &mw_prefix.searchindex(si_text) INDEXTYPE IS ctxsys.context;
658 CREATE TABLE &mw_prefix.l10n_cache (
659 lc_lang varchar2(32) NOT NULL,
660 lc_key varchar2(255) NOT NULL,
661 lc_value clob NOT NULL
663 CREATE INDEX &mw_prefix.l10n_cache_u01 ON &mw_prefix.l10n_cache (lc_lang, lc_key);
665 CREATE TABLE &mw_prefix.module_deps (
666 md_module VARCHAR2(255) NOT NULL,
667 md_skin VARCHAR2(32) NOT NULL,
668 md_deps BLOB NOT NULL
670 CREATE UNIQUE INDEX &mw_prefix.module_deps_u01 ON &mw_prefix.module_deps (md_module, md_skin);
672 CREATE SEQUENCE sites_site_id_seq MINVALUE 0 START WITH 0;
673 CREATE TABLE &mw_prefix.sites (
674 site_id NUMBER NOT NULL,
675 site_global_key VARCHAR2(32) NOT NULL,
676 site_type VARCHAR2(32) NOT NULL,
677 site_group VARCHAR2(32) NOT NULL,
678 site_source VARCHAR2(32) NOT NULL,
679 site_language VARCHAR2(32) NOT NULL,
680 site_protocol VARCHAR2(32) NOT NULL,
681 site_domain VARCHAR2(255) NOT NULL,
682 site_data BLOB NOT NULL,
683 site_forward NUMBER(1) NOT NULL,
684 site_config BLOB NOT NULL
686 ALTER TABLE &mw_prefix.sites ADD CONSTRAINT &mw_prefix.sites_pk PRIMARY KEY (site_id);
687 CREATE UNIQUE INDEX &mw_prefix.sites_u01 ON &mw_prefix.sites (site_global_key);
688 CREATE INDEX &mw_prefix.sites_i01 ON &mw_prefix.sites (site_type);
689 CREATE INDEX &mw_prefix.sites_i02 ON &mw_prefix.sites (site_group);
690 CREATE INDEX &mw_prefix.sites_i03 ON &mw_prefix.sites (site_source);
691 CREATE INDEX &mw_prefix.sites_i04 ON &mw_prefix.sites (site_language);
692 CREATE INDEX &mw_prefix.sites_i05 ON &mw_prefix.sites (site_protocol);
693 CREATE INDEX &mw_prefix.sites_i06 ON &mw_prefix.sites (site_domain);
694 CREATE INDEX &mw_prefix.sites_i07 ON &mw_prefix.sites (site_forward);
696 CREATE TABLE &mw_prefix.site_identifiers (
697 si_site NUMBER NOT NULL,
698 si_type VARCHAR2(32) NOT NULL,
699 si_key VARCHAR2(32) NOT NULL
701 CREATE UNIQUE INDEX &mw_prefix.site_identifiers_u01 ON &mw_prefix.site_identifiers (si_type, si_key);
702 CREATE INDEX &mw_prefix.site_identifiers_i01 ON &mw_prefix.site_identifiers (si_site);
703 CREATE INDEX &mw_prefix.site_identifiers_i02 ON &mw_prefix.site_identifiers (si_key);
705 -- do not prefix this table as it breaks parserTests
706 CREATE TABLE wiki_field_info_full (
707 table_name VARCHAR2(35) NOT NULL,
708 column_name VARCHAR2(35) NOT NULL,
709 data_default VARCHAR2(4000),
710 data_length NUMBER NOT NULL,
711 data_type VARCHAR2(106),
712 not_null CHAR(1) NOT NULL,
717 ALTER TABLE wiki_field_info_full ADD CONSTRAINT wiki_field_info_full_pk PRIMARY KEY (table_name, column_name);
720 CREATE PROCEDURE fill_wiki_info IS
722 DELETE wiki_field_info_full;
724 FOR x_rec IN (SELECT t.table_name table_name, t.column_name,
725 t.data_default, t.data_length, t.data_type,
726 DECODE (t.nullable, 'Y', '1', 'N', '0') not_null,
728 FROM user_cons_columns ucc,
730 WHERE ucc.table_name = t.table_name
731 AND ucc.column_name = t.column_name
732 AND uc.constraint_name = ucc.constraint_name
733 AND uc.constraint_type = 'P'
734 AND ROWNUM < 2) prim,
736 FROM user_ind_columns uic,
738 WHERE uic.table_name = t.table_name
739 AND uic.column_name = t.column_name
740 AND ui.index_name = uic.index_name
741 AND ui.uniqueness = 'UNIQUE'
742 AND ROWNUM < 2) uniq,
744 FROM user_ind_columns uic,
746 WHERE uic.table_name = t.table_name
747 AND uic.column_name = t.column_name
748 AND ui.index_name = uic.index_name
749 AND ui.uniqueness = 'NONUNIQUE'
750 AND ROWNUM < 2) nonuniq
751 FROM user_tab_columns t, user_tables ut
752 WHERE ut.table_name = t.table_name)
754 INSERT INTO wiki_field_info_full
755 (table_name, column_name,
756 data_default, data_length,
757 data_type, not_null, prim,
760 VALUES (x_rec.table_name, x_rec.column_name,
761 x_rec.data_default, x_rec.data_length,
762 x_rec.data_type, x_rec.not_null, x_rec.prim,
763 x_rec.uniq, x_rec.nonuniq
771 CREATE OR REPLACE PROCEDURE duplicate_table(p_tabname IN VARCHAR2,
772 p_oldprefix IN VARCHAR2,
773 p_newprefix IN VARCHAR2,
774 p_temporary IN BOOLEAN) IS
775 e_table_not_exist EXCEPTION;
776 PRAGMA EXCEPTION_INIT(e_table_not_exist, -00942);
777 l_temp_ei_sql VARCHAR2(2000);
778 l_temporary BOOLEAN := p_temporary;
781 EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname ||
782 ' CASCADE CONSTRAINTS PURGE';
784 WHEN e_table_not_exist THEN
787 IF (p_tabname = 'SEARCHINDEX') THEN
788 l_temporary := FALSE;
790 IF (l_temporary) THEN
791 EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix ||
793 ' ON COMMIT PRESERVE ROWS AS SELECT * FROM ' ||
794 p_oldprefix || p_tabname || ' WHERE ROWNUM = 0';
796 EXECUTE IMMEDIATE 'CREATE TABLE ' || p_newprefix || p_tabname ||
797 ' AS SELECT * FROM ' || p_oldprefix || p_tabname ||
800 FOR rc IN (SELECT column_name, data_default
801 FROM user_tab_columns
802 WHERE table_name = p_oldprefix || p_tabname
803 AND data_default IS NOT NULL) LOOP
804 EXECUTE IMMEDIATE 'ALTER TABLE ' || p_newprefix || p_tabname ||
805 ' MODIFY ' || rc.column_name || ' DEFAULT ' ||
806 SUBSTR(rc.data_default, 1, 2000);
808 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('CONSTRAINT',
812 USER || '"."' || p_oldprefix,
813 USER || '"."' || p_newprefix),
814 '"' || constraint_name || '"',
815 '"' || p_newprefix || constraint_name || '"') DDLVC2,
817 FROM user_constraints uc
818 WHERE table_name = p_oldprefix || p_tabname
819 AND constraint_type = 'P') LOOP
820 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
821 l_temp_ei_sql := SUBSTR(l_temp_ei_sql,
825 INSTR(l_temp_ei_sql, 'PRIMARY KEY') + 1) + 1);
826 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
827 EXECUTE IMMEDIATE l_temp_ei_sql;
830 IF (NOT l_temporary) THEN
831 FOR rc IN (SELECT REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('REF_CONSTRAINT',
835 USER || '"."' || p_oldprefix,
836 USER || '"."' || p_newprefix) DDLVC2,
838 FROM user_constraints uc
839 WHERE table_name = p_oldprefix || p_tabname
840 AND constraint_type = 'R') LOOP
841 IF nvl(length(l_temp_ei_sql), 0) > 0 AND
842 INSTR(l_temp_ei_sql, 'PRIMARY KEY') = 0 THEN
843 EXECUTE IMMEDIATE l_temp_ei_sql;
847 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
851 USER || '"."' || p_oldprefix,
852 USER || '"."' || p_newprefix),
853 '"' || index_name || '"',
854 '"' || p_newprefix || index_name || '"') DDLVC2,
858 WHERE table_name = p_oldprefix || p_tabname
859 AND index_type NOT IN ('LOB', 'DOMAIN')
862 FROM user_constraints
863 WHERE table_name = ui.table_name
864 AND constraint_name = ui.index_name)) LOOP
865 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
866 l_temp_ei_sql := SUBSTR(l_temp_ei_sql,
871 '"' || USER || '"."' || p_newprefix || '"') + 1) + 1);
872 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
873 EXECUTE IMMEDIATE l_temp_ei_sql;
876 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
880 USER || '"."' || p_oldprefix,
881 USER || '"."' || p_newprefix),
882 '"' || index_name || '"',
883 '"' || p_newprefix || index_name || '"') DDLVC2,
887 WHERE table_name = p_oldprefix || p_tabname
888 AND index_type = 'DOMAIN'
891 FROM user_constraints
892 WHERE table_name = ui.table_name
893 AND constraint_name = ui.index_name)) LOOP
894 l_temp_ei_sql := rc.ddlvc2;
895 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
896 EXECUTE IMMEDIATE l_temp_ei_sql;
899 FOR rc IN (SELECT REPLACE(REPLACE(UPPER(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('TRIGGER',
903 USER || '"."' || p_oldprefix,
904 USER || '"."' || p_newprefix),
905 ' ON ' || p_oldprefix || p_tabname,
906 ' ON ' || p_newprefix || p_tabname) DDLVC2,
909 WHERE table_name = p_oldprefix || p_tabname) LOOP
910 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'ALTER ') - 1);
911 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
912 EXECUTE IMMEDIATE l_temp_ei_sql;
920 CREATE OR REPLACE FUNCTION BITOR (x IN NUMBER, y IN NUMBER) RETURN NUMBER AS
922 RETURN (x + y - BITAND(x, y));
927 CREATE OR REPLACE FUNCTION BITNOT (x IN NUMBER) RETURN NUMBER AS
929 RETURN (4294967295 - x);
933 CREATE OR REPLACE TYPE GET_OUTPUT_TYPE IS TABLE OF VARCHAR2(255);
936 CREATE OR REPLACE FUNCTION GET_OUTPUT_LINES RETURN GET_OUTPUT_TYPE PIPELINED AS
937 v_line VARCHAR2(255);
938 v_status INTEGER := 0;
942 DBMS_OUTPUT.GET_LINE(v_line, v_status);
943 IF (v_status = 0) THEN RETURN; END IF;
954 CREATE OR REPLACE FUNCTION GET_SEQUENCE_VALUE(seq IN VARCHAR2) RETURN NUMBER AS
957 EXECUTE IMMEDIATE 'SELECT '||seq||'.NEXTVAL INTO :outVar FROM DUAL' INTO v_value;