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,
223 el_index_60 VARBINARY(60) NOT NULL DEFAULT ''
225 ALTER TABLE &mw_prefix.externallinks ADD CONSTRAINT &mw_prefix.externallinks_pk PRIMARY KEY (el_id);
226 ALTER TABLE &mw_prefix.externallinks ADD CONSTRAINT &mw_prefix.externallinks_fk1 FOREIGN KEY (el_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
227 CREATE INDEX &mw_prefix.externallinks_i01 ON &mw_prefix.externallinks (el_from, el_to);
228 CREATE INDEX &mw_prefix.externallinks_i02 ON &mw_prefix.externallinks (el_to, el_from);
229 CREATE INDEX &mw_prefix.externallinks_i03 ON &mw_prefix.externallinks (el_index);
230 CREATE INDEX &mw_prefix.externallinks_i04 ON &mw_prefix.externallinks (el_index_60, el_id);
231 CREATE INDEX &mw_prefix.externallinks_i05 ON &mw_prefix.externallinks (el_from, el_index_60, el_id);
233 CREATE TABLE &mw_prefix.langlinks (
234 ll_from NUMBER NOT NULL,
235 ll_lang VARCHAR2(20),
236 ll_title VARCHAR2(255)
238 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;
239 CREATE UNIQUE INDEX &mw_prefix.langlinks_u01 ON &mw_prefix.langlinks (ll_from, ll_lang);
240 CREATE INDEX &mw_prefix.langlinks_i01 ON &mw_prefix.langlinks (ll_lang, ll_title);
242 CREATE TABLE &mw_prefix.iwlinks (
243 iwl_from NUMBER DEFAULT 0 NOT NULL,
244 iwl_prefix VARCHAR2(20),
245 iwl_title VARCHAR2(255)
247 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui01 ON &mw_prefix.iwlinks (iwl_from, iwl_prefix, iwl_title);
248 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui02 ON &mw_prefix.iwlinks (iwl_prefix, iwl_title, iwl_from);
250 CREATE TABLE &mw_prefix.site_stats (
251 ss_row_id NUMBER NOT NULL ,
252 ss_total_edits NUMBER DEFAULT 0,
253 ss_good_articles NUMBER DEFAULT 0,
254 ss_total_pages NUMBER DEFAULT -1,
255 ss_users NUMBER DEFAULT -1,
256 ss_active_users NUMBER DEFAULT -1,
257 ss_images NUMBER DEFAULT 0
259 CREATE UNIQUE INDEX &mw_prefix.site_stats_u01 ON &mw_prefix.site_stats (ss_row_id);
261 CREATE SEQUENCE ipblocks_ipb_id_seq;
262 CREATE TABLE &mw_prefix.ipblocks (
263 ipb_id NUMBER NOT NULL,
264 ipb_address VARCHAR2(255) NULL,
265 ipb_user NUMBER DEFAULT 0 NOT NULL,
266 ipb_by NUMBER DEFAULT 0 NOT NULL,
267 ipb_by_text VARCHAR2(255) NULL,
268 ipb_reason VARCHAR2(255) NOT NULL,
269 ipb_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
270 ipb_auto CHAR(1) DEFAULT '0' NOT NULL,
271 ipb_anon_only CHAR(1) DEFAULT '0' NOT NULL,
272 ipb_create_account CHAR(1) DEFAULT '1' NOT NULL,
273 ipb_enable_autoblock CHAR(1) DEFAULT '1' NOT NULL,
274 ipb_expiry TIMESTAMP(6) WITH TIME ZONE NOT NULL,
275 ipb_range_start VARCHAR2(255),
276 ipb_range_end VARCHAR2(255),
277 ipb_deleted CHAR(1) DEFAULT '0' NOT NULL,
278 ipb_block_email CHAR(1) DEFAULT '0' NOT NULL,
279 ipb_allow_usertalk CHAR(1) DEFAULT '0' NOT NULL,
280 ipb_parent_block_id NUMBER DEFAULT NULL
282 ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_pk PRIMARY KEY (ipb_id);
283 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;
284 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;
285 CREATE UNIQUE INDEX &mw_prefix.ipblocks_u01 ON &mw_prefix.ipblocks (ipb_address, ipb_user, ipb_auto, ipb_anon_only);
286 CREATE INDEX &mw_prefix.ipblocks_i01 ON &mw_prefix.ipblocks (ipb_user);
287 CREATE INDEX &mw_prefix.ipblocks_i02 ON &mw_prefix.ipblocks (ipb_range_start, ipb_range_end);
288 CREATE INDEX &mw_prefix.ipblocks_i03 ON &mw_prefix.ipblocks (ipb_timestamp);
289 CREATE INDEX &mw_prefix.ipblocks_i04 ON &mw_prefix.ipblocks (ipb_expiry);
290 CREATE INDEX &mw_prefix.ipblocks_i05 ON &mw_prefix.ipblocks (ipb_parent_block_id);
292 CREATE TABLE &mw_prefix.image (
293 img_name VARCHAR2(255) NOT NULL,
294 img_size NUMBER DEFAULT 0 NOT NULL,
295 img_width NUMBER DEFAULT 0 NOT NULL,
296 img_height NUMBER DEFAULT 0 NOT NULL,
298 img_bits NUMBER DEFAULT 0 NOT NULL,
299 img_media_type VARCHAR2(32),
300 img_major_mime VARCHAR2(32) DEFAULT 'unknown',
301 img_minor_mime VARCHAR2(100) DEFAULT 'unknown',
302 img_description VARCHAR2(255),
303 img_user NUMBER DEFAULT 0 NOT NULL,
304 img_user_text VARCHAR2(255) NOT NULL,
305 img_timestamp TIMESTAMP(6) WITH TIME ZONE,
306 img_sha1 VARCHAR2(32)
308 ALTER TABLE &mw_prefix.image ADD CONSTRAINT &mw_prefix.image_pk PRIMARY KEY (img_name);
309 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;
310 CREATE INDEX &mw_prefix.image_i01 ON &mw_prefix.image (img_user_text,img_timestamp);
311 CREATE INDEX &mw_prefix.image_i02 ON &mw_prefix.image (img_size);
312 CREATE INDEX &mw_prefix.image_i03 ON &mw_prefix.image (img_timestamp);
313 CREATE INDEX &mw_prefix.image_i04 ON &mw_prefix.image (img_sha1);
316 CREATE TABLE &mw_prefix.oldimage (
317 oi_name VARCHAR2(255) DEFAULT 0 NOT NULL,
318 oi_archive_name VARCHAR2(255),
319 oi_size NUMBER DEFAULT 0 NOT NULL,
320 oi_width NUMBER DEFAULT 0 NOT NULL,
321 oi_height NUMBER DEFAULT 0 NOT NULL,
322 oi_bits NUMBER DEFAULT 0 NOT NULL,
323 oi_description VARCHAR2(255),
324 oi_user NUMBER DEFAULT 0 NOT NULL,
325 oi_user_text VARCHAR2(255) NOT NULL,
326 oi_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
328 oi_media_type VARCHAR2(32) DEFAULT NULL,
329 oi_major_mime VARCHAR2(32) DEFAULT 'unknown',
330 oi_minor_mime VARCHAR2(100) DEFAULT 'unknown',
331 oi_deleted NUMBER DEFAULT 0 NOT NULL,
334 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;
335 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;
336 CREATE INDEX &mw_prefix.oldimage_i01 ON &mw_prefix.oldimage (oi_user_text,oi_timestamp);
337 CREATE INDEX &mw_prefix.oldimage_i02 ON &mw_prefix.oldimage (oi_name,oi_timestamp);
338 CREATE INDEX &mw_prefix.oldimage_i03 ON &mw_prefix.oldimage (oi_name,oi_archive_name);
339 CREATE INDEX &mw_prefix.oldimage_i04 ON &mw_prefix.oldimage (oi_sha1);
342 CREATE SEQUENCE filearchive_fa_id_seq;
343 CREATE TABLE &mw_prefix.filearchive (
344 fa_id NUMBER NOT NULL,
345 fa_name VARCHAR2(255) NOT NULL,
346 fa_archive_name VARCHAR2(255),
347 fa_storage_group VARCHAR2(16),
348 fa_storage_key VARCHAR2(64),
349 fa_deleted_user NUMBER DEFAULT 0 NOT NULL,
350 fa_deleted_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
351 fa_deleted_reason CLOB,
352 fa_size NUMBER DEFAULT 0 NOT NULL,
353 fa_width NUMBER DEFAULT 0 NOT NULL,
354 fa_height NUMBER DEFAULT 0 NOT NULL,
356 fa_bits NUMBER DEFAULT 0 NOT NULL,
357 fa_media_type VARCHAR2(32) DEFAULT NULL,
358 fa_major_mime VARCHAR2(32) DEFAULT 'unknown',
359 fa_minor_mime VARCHAR2(100) DEFAULT 'unknown',
360 fa_description VARCHAR2(255),
361 fa_user NUMBER DEFAULT 0 NOT NULL,
362 fa_user_text VARCHAR2(255) NOT NULL,
363 fa_timestamp TIMESTAMP(6) WITH TIME ZONE,
364 fa_deleted NUMBER DEFAULT 0 NOT NULL,
367 ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_pk PRIMARY KEY (fa_id);
368 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;
369 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;
370 CREATE INDEX &mw_prefix.filearchive_i01 ON &mw_prefix.filearchive (fa_name, fa_timestamp);
371 CREATE INDEX &mw_prefix.filearchive_i02 ON &mw_prefix.filearchive (fa_storage_group, fa_storage_key);
372 CREATE INDEX &mw_prefix.filearchive_i03 ON &mw_prefix.filearchive (fa_deleted_timestamp);
373 CREATE INDEX &mw_prefix.filearchive_i04 ON &mw_prefix.filearchive (fa_user_text,fa_timestamp);
374 CREATE INDEX &mw_prefix.filearchive_i05 ON &mw_prefix.filearchive (fa_sha1);
376 CREATE SEQUENCE uploadstash_us_id_seq;
377 CREATE TABLE &mw_prefix.uploadstash (
378 us_id NUMBER NOT NULL,
379 us_user NUMBER DEFAULT 0 NOT NULL,
380 us_key VARCHAR2(255) NOT NULL,
381 us_orig_path VARCHAR2(255) NOT NULL,
382 us_path VARCHAR2(255) NOT NULL,
383 us_source_type VARCHAR2(50),
384 us_timestamp TIMESTAMP(6) WITH TIME ZONE,
385 us_status VARCHAR2(50) NOT NULL,
387 us_size NUMBER NOT NULL,
388 us_sha1 VARCHAR2(32) NOT NULL,
389 us_mime VARCHAR2(255),
390 us_media_type VARCHAR2(32) DEFAULT NULL,
391 us_image_width NUMBER,
392 us_image_height NUMBER,
393 us_image_bits NUMBER,
396 ALTER TABLE &mw_prefix.uploadstash ADD CONSTRAINT &mw_prefix.uploadstash_pk PRIMARY KEY (us_id);
397 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;
398 CREATE INDEX &mw_prefix.uploadstash_i01 ON &mw_prefix.uploadstash (us_user);
399 CREATE INDEX &mw_prefix.uploadstash_i02 ON &mw_prefix.uploadstash (us_timestamp);
400 CREATE UNIQUE INDEX &mw_prefix.uploadstash_u01 ON &mw_prefix.uploadstash (us_key);
402 CREATE SEQUENCE recentchanges_rc_id_seq;
403 CREATE TABLE &mw_prefix.recentchanges (
404 rc_id NUMBER NOT NULL,
405 rc_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
406 rc_cur_time TIMESTAMP(6) WITH TIME ZONE,
407 rc_user NUMBER DEFAULT 0 NOT NULL,
408 rc_user_text VARCHAR2(255) NOT NULL,
409 rc_namespace NUMBER DEFAULT 0 NOT NULL,
410 rc_title VARCHAR2(255) NOT NULL,
411 rc_comment VARCHAR2(255),
412 rc_minor CHAR(1) DEFAULT '0' NOT NULL,
413 rc_bot CHAR(1) DEFAULT '0' NOT NULL,
414 rc_new CHAR(1) DEFAULT '0' NOT NULL,
415 rc_cur_id NUMBER DEFAULT 0 NOT NULL,
416 rc_this_oldid NUMBER DEFAULT 0 NOT NULL,
417 rc_last_oldid NUMBER DEFAULT 0 NOT NULL,
418 rc_type CHAR(1) DEFAULT '0' NOT NULL,
419 rc_source VARCHAR2(16),
420 rc_patrolled CHAR(1) DEFAULT '0' NOT NULL,
424 rc_deleted CHAR(1) DEFAULT '0' NOT NULL,
425 rc_logid NUMBER DEFAULT 0 NOT NULL,
426 rc_log_type VARCHAR2(255),
427 rc_log_action VARCHAR2(255),
430 ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_pk PRIMARY KEY (rc_id);
431 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;
432 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;
433 CREATE INDEX &mw_prefix.recentchanges_i01 ON &mw_prefix.recentchanges (rc_timestamp);
434 CREATE INDEX &mw_prefix.recentchanges_i02 ON &mw_prefix.recentchanges (rc_namespace, rc_title);
435 CREATE INDEX &mw_prefix.recentchanges_i03 ON &mw_prefix.recentchanges (rc_cur_id);
436 CREATE INDEX &mw_prefix.recentchanges_i04 ON &mw_prefix.recentchanges (rc_new,rc_namespace,rc_timestamp);
437 CREATE INDEX &mw_prefix.recentchanges_i05 ON &mw_prefix.recentchanges (rc_ip);
438 CREATE INDEX &mw_prefix.recentchanges_i06 ON &mw_prefix.recentchanges (rc_namespace, rc_user_text);
439 CREATE INDEX &mw_prefix.recentchanges_i07 ON &mw_prefix.recentchanges (rc_user_text, rc_timestamp);
440 CREATE INDEX &mw_prefix.recentchanges_i08 ON &mw_prefix.recentchanges (rc_namespace, rc_type, rc_patrolled, rc_timestamp);
442 CREATE TABLE &mw_prefix.watchlist (
443 wl_id NUMBER NOT NULL,
444 wl_user NUMBER NOT NULL,
445 wl_namespace NUMBER DEFAULT 0 NOT NULL,
446 wl_title VARCHAR2(255) NOT NULL,
447 wl_notificationtimestamp TIMESTAMP(6) WITH TIME ZONE
449 ALTER TABLE &mw_prefix.watchlist ADD CONSTRAINT &mw_prefix.watchlist_pk PRIMARY KEY (wl_id);
450 ALTER TABLE &mw_prefix.watchlist ADD CONSTRAINT &mw_prefix.watchlist_fk1 FOREIGN KEY (wl_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
451 CREATE UNIQUE INDEX &mw_prefix.watchlist_u01 ON &mw_prefix.watchlist (wl_user, wl_namespace, wl_title);
452 CREATE INDEX &mw_prefix.watchlist_i01 ON &mw_prefix.watchlist (wl_namespace, wl_title);
455 CREATE TABLE &mw_prefix.searchindex (
456 si_page NUMBER NOT NULL,
457 si_title VARCHAR2(255),
458 si_text CLOB NOT NULL
460 CREATE UNIQUE INDEX &mw_prefix.searchindex_u01 ON &mw_prefix.searchindex (si_page);
462 CREATE TABLE &mw_prefix.interwiki (
463 iw_prefix VARCHAR2(32) NOT NULL,
464 iw_url VARCHAR2(127) NOT NULL,
465 iw_api BLOB NOT NULL,
466 iw_wikiid VARCHAR2(64),
467 iw_local CHAR(1) NOT NULL,
468 iw_trans CHAR(1) DEFAULT '0' NOT NULL
470 CREATE UNIQUE INDEX &mw_prefix.interwiki_u01 ON &mw_prefix.interwiki (iw_prefix);
472 CREATE TABLE &mw_prefix.querycache (
473 qc_type VARCHAR2(32) NOT NULL,
474 qc_value NUMBER DEFAULT 0 NOT NULL,
475 qc_namespace NUMBER DEFAULT 0 NOT NULL,
476 qc_title VARCHAR2(255) NOT NULL
478 CREATE INDEX &mw_prefix.querycache_u01 ON &mw_prefix.querycache (qc_type,qc_value);
480 CREATE TABLE &mw_prefix.objectcache (
481 keyname VARCHAR2(255) ,
483 exptime TIMESTAMP(6) WITH TIME ZONE NOT NULL
485 CREATE INDEX &mw_prefix.objectcache_i01 ON &mw_prefix.objectcache (exptime);
487 CREATE TABLE &mw_prefix.transcache (
488 tc_url VARCHAR2(255) NOT NULL,
489 tc_contents CLOB NOT NULL,
490 tc_time TIMESTAMP(6) WITH TIME ZONE NOT NULL
492 CREATE UNIQUE INDEX &mw_prefix.transcache_u01 ON &mw_prefix.transcache (tc_url);
495 CREATE SEQUENCE logging_log_id_seq;
496 CREATE TABLE &mw_prefix.logging (
497 log_id NUMBER NOT NULL,
498 log_type VARCHAR2(10) NOT NULL,
499 log_action VARCHAR2(10) NOT NULL,
500 log_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
501 log_user NUMBER DEFAULT 0 NOT NULL,
502 log_user_text VARCHAR2(255),
503 log_namespace NUMBER DEFAULT 0 NOT NULL,
504 log_title VARCHAR2(255) NOT NULL,
506 log_comment VARCHAR2(255),
508 log_deleted CHAR(1) DEFAULT '0' NOT NULL
510 ALTER TABLE &mw_prefix.logging ADD CONSTRAINT &mw_prefix.logging_pk PRIMARY KEY (log_id);
511 ALTER TABLE &mw_prefix.logging ADD CONSTRAINT &mw_prefix.logging_fk1 FOREIGN KEY (log_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
512 CREATE INDEX &mw_prefix.logging_i01 ON &mw_prefix.logging (log_type, log_timestamp);
513 CREATE INDEX &mw_prefix.logging_i02 ON &mw_prefix.logging (log_user, log_timestamp);
514 CREATE INDEX &mw_prefix.logging_i03 ON &mw_prefix.logging (log_namespace, log_title, log_timestamp);
515 CREATE INDEX &mw_prefix.logging_i04 ON &mw_prefix.logging (log_timestamp);
516 CREATE INDEX &mw_prefix.logging_i05 ON &mw_prefix.logging (log_type, log_action, log_timestamp);
517 CREATE INDEX &mw_prefix.logging_i06 ON &mw_prefix.logging (log_user_text, log_type, log_timestamp);
518 CREATE INDEX &mw_prefix.logging_i07 ON &mw_prefix.logging (log_user_text, log_timestamp);
520 CREATE TABLE &mw_prefix.log_search (
521 ls_field VARCHAR2(32) NOT NULL,
522 ls_value VARCHAR2(255) NOT NULL,
523 ls_log_id NuMBER DEFAULT 0 NOT NULL
525 ALTER TABLE &mw_prefix.log_search ADD CONSTRAINT log_search_pk PRIMARY KEY (ls_field,ls_value,ls_log_id);
526 CREATE INDEX &mw_prefix.log_search_i01 ON &mw_prefix.log_search (ls_log_id);
529 CREATE SEQUENCE job_job_id_seq;
530 CREATE TABLE &mw_prefix.job (
531 job_id NUMBER NOT NULL,
532 job_cmd VARCHAR2(60) NOT NULL,
533 job_namespace NUMBER DEFAULT 0 NOT NULL,
534 job_title VARCHAR2(255) NOT NULL,
535 job_timestamp TIMESTAMP(6) WITH TIME ZONE NULL,
536 job_params CLOB NOT NULL,
537 job_random NUMBER DEFAULT 0 NOT NULL,
538 job_token VARCHAR2(32),
539 job_token_timestamp TIMESTAMP(6) WITH TIME ZONE,
540 job_sha1 VARCHAR2(32),
541 job_attempts NUMBER DEFAULT 0 NOT NULL
543 ALTER TABLE &mw_prefix.job ADD CONSTRAINT &mw_prefix.job_pk PRIMARY KEY (job_id);
544 CREATE INDEX &mw_prefix.job_i01 ON &mw_prefix.job (job_cmd, job_namespace, job_title);
545 CREATE INDEX &mw_prefix.job_i02 ON &mw_prefix.job (job_timestamp);
546 CREATE INDEX &mw_prefix.job_i03 ON &mw_prefix.job (job_sha1);
547 CREATE INDEX &mw_prefix.job_i04 ON &mw_prefix.job (job_cmd,job_token,job_random);
548 CREATE INDEX &mw_prefix.job_i05 ON &mw_prefix.job (job_attempts);
550 CREATE TABLE &mw_prefix.querycache_info (
551 qci_type VARCHAR2(32) NOT NULL,
552 qci_timestamp TIMESTAMP(6) WITH TIME ZONE NULL
554 CREATE UNIQUE INDEX &mw_prefix.querycache_info_u01 ON &mw_prefix.querycache_info (qci_type);
556 CREATE TABLE &mw_prefix.redirect (
557 rd_from NUMBER NOT NULL,
558 rd_namespace NUMBER DEFAULT 0 NOT NULL,
559 rd_title VARCHAR2(255) NOT NULL,
560 rd_interwiki VARCHAR2(32),
561 rd_fragment VARCHAR2(255)
563 ALTER TABLE &mw_prefix.redirect ADD CONSTRAINT &mw_prefix.redirect_fk1 FOREIGN KEY (rd_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
564 CREATE INDEX &mw_prefix.redirect_i01 ON &mw_prefix.redirect (rd_namespace,rd_title,rd_from);
566 CREATE TABLE &mw_prefix.querycachetwo (
567 qcc_type VARCHAR2(32) NOT NULL,
568 qcc_value NUMBER DEFAULT 0 NOT NULL,
569 qcc_namespace NUMBER DEFAULT 0 NOT NULL,
570 qcc_title VARCHAR2(255),
571 qcc_namespacetwo NUMBER DEFAULT 0 NOT NULL,
572 qcc_titletwo VARCHAR2(255)
574 CREATE INDEX &mw_prefix.querycachetwo_i01 ON &mw_prefix.querycachetwo (qcc_type,qcc_value);
575 CREATE INDEX &mw_prefix.querycachetwo_i02 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespace,qcc_title);
576 CREATE INDEX &mw_prefix.querycachetwo_i03 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
578 CREATE SEQUENCE page_restrictions_pr_id_seq;
579 CREATE TABLE &mw_prefix.page_restrictions (
580 pr_id NUMBER NOT NULL,
581 pr_page NUMBER NOT NULL,
582 pr_type VARCHAR2(255) NOT NULL,
583 pr_level VARCHAR2(255) NOT NULL,
584 pr_cascade NUMBER NOT NULL,
586 pr_expiry TIMESTAMP(6) WITH TIME ZONE NULL
588 ALTER TABLE &mw_prefix.page_restrictions ADD CONSTRAINT &mw_prefix.page_restrictions_pk PRIMARY KEY (pr_id);
589 ALTER TABLE &mw_prefix.page_restrictions ADD CONSTRAINT &mw_prefix.page_restrictions_fk1 FOREIGN KEY (pr_page) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
590 CREATE UNIQUE INDEX &mw_prefix.page_restrictions_u01 ON &mw_prefix.page_restrictions (pr_page,pr_type);
591 CREATE INDEX &mw_prefix.page_restrictions_i01 ON &mw_prefix.page_restrictions (pr_type,pr_level);
592 CREATE INDEX &mw_prefix.page_restrictions_i02 ON &mw_prefix.page_restrictions (pr_level);
593 CREATE INDEX &mw_prefix.page_restrictions_i03 ON &mw_prefix.page_restrictions (pr_cascade);
595 CREATE TABLE &mw_prefix.protected_titles (
596 pt_namespace NUMBER DEFAULT 0 NOT NULL,
597 pt_title VARCHAR2(255) NOT NULL,
598 pt_user NUMBER NOT NULL,
599 pt_reason VARCHAR2(255),
600 pt_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
601 pt_expiry VARCHAR2(14) NOT NULL,
602 pt_create_perm VARCHAR2(60) NOT NULL
604 CREATE UNIQUE INDEX &mw_prefix.protected_titles_u01 ON &mw_prefix.protected_titles (pt_namespace,pt_title);
605 CREATE INDEX &mw_prefix.protected_titles_i01 ON &mw_prefix.protected_titles (pt_timestamp);
607 CREATE TABLE &mw_prefix.page_props (
608 pp_page NUMBER NOT NULL,
609 pp_propname VARCHAR2(60) NOT NULL,
610 pp_value BLOB NOT NULL
612 CREATE UNIQUE INDEX &mw_prefix.page_props_u01 ON &mw_prefix.page_props (pp_page,pp_propname);
615 CREATE TABLE &mw_prefix.updatelog (
616 ul_key VARCHAR2(255) NOT NULL,
619 ALTER TABLE &mw_prefix.updatelog ADD CONSTRAINT &mw_prefix.updatelog_pk PRIMARY KEY (ul_key);
621 CREATE TABLE &mw_prefix.change_tag (
622 ct_id NUMBER NOT NULL,
623 ct_rc_id NUMBER NULL,
624 ct_log_id NUMBER NULL,
625 ct_rev_id NUMBER NULL,
626 ct_tag VARCHAR2(255) NOT NULL,
629 ALTER TABLE &mw_prefix.change_tag ADD CONSTRAINT &mw_prefix.change_tag_pk PRIMARY KEY (ct_id);
630 CREATE UNIQUE INDEX &mw_prefix.change_tag_u01 ON &mw_prefix.change_tag (ct_rc_id,ct_tag);
631 CREATE UNIQUE INDEX &mw_prefix.change_tag_u02 ON &mw_prefix.change_tag (ct_log_id,ct_tag);
632 CREATE UNIQUE INDEX &mw_prefix.change_tag_u03 ON &mw_prefix.change_tag (ct_rev_id,ct_tag);
633 CREATE INDEX &mw_prefix.change_tag_i01 ON &mw_prefix.change_tag (ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
635 CREATE TABLE &mw_prefix.tag_summary (
636 ts_id NUMBER NOT NULL,
637 ts_rc_id NUMBER NULL,
638 ts_log_id NUMBER NULL,
639 ts_rev_id NUMBER NULL,
640 ts_tags BLOB NOT NULL
642 ALTER TABLE &mw_prefix.tag_summary ADD CONSTRAINT &mw_prefix.tag_summary_pk PRIMARY KEY (ts_id);
643 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u01 ON &mw_prefix.tag_summary (ts_rc_id);
644 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u02 ON &mw_prefix.tag_summary (ts_log_id);
645 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u03 ON &mw_prefix.tag_summary (ts_rev_id);
647 CREATE TABLE &mw_prefix.valid_tag (
648 vt_tag VARCHAR2(255) NOT NULL
650 ALTER TABLE &mw_prefix.valid_tag ADD CONSTRAINT &mw_prefix.valid_tag_pk PRIMARY KEY (vt_tag);
652 -- This table is not used unless profiling is turned on
653 --CREATE TABLE &mw_prefix.profiling (
654 -- pf_count NUMBER DEFAULT 0 NOT NULL,
655 -- pf_time NUMBER(18,10) DEFAULT 0 NOT NULL,
656 -- pf_memory NUMBER(18,10) DEFAULT 0 NOT NULL,
657 -- pf_name VARCHAR2(255),
658 -- pf_server VARCHAR2(30)
660 --CREATE UNIQUE INDEX &mw_prefix.profiling_u01 ON &mw_prefix.profiling (pf_name, pf_server);
662 CREATE INDEX &mw_prefix.si_title_idx ON &mw_prefix.searchindex(si_title) INDEXTYPE IS ctxsys.context;
663 CREATE INDEX &mw_prefix.si_text_idx ON &mw_prefix.searchindex(si_text) INDEXTYPE IS ctxsys.context;
665 CREATE TABLE &mw_prefix.l10n_cache (
666 lc_lang varchar2(32) NOT NULL,
667 lc_key varchar2(255) NOT NULL,
668 lc_value clob NOT NULL
670 CREATE INDEX &mw_prefix.l10n_cache_u01 ON &mw_prefix.l10n_cache (lc_lang, lc_key);
672 CREATE TABLE &mw_prefix.module_deps (
673 md_module VARCHAR2(255) NOT NULL,
674 md_skin VARCHAR2(32) NOT NULL,
675 md_deps BLOB NOT NULL
677 CREATE UNIQUE INDEX &mw_prefix.module_deps_u01 ON &mw_prefix.module_deps (md_module, md_skin);
679 CREATE SEQUENCE sites_site_id_seq MINVALUE 0 START WITH 0;
680 CREATE TABLE &mw_prefix.sites (
681 site_id NUMBER NOT NULL,
682 site_global_key VARCHAR2(32) NOT NULL,
683 site_type VARCHAR2(32) NOT NULL,
684 site_group VARCHAR2(32) NOT NULL,
685 site_source VARCHAR2(32) NOT NULL,
686 site_language VARCHAR2(32) NOT NULL,
687 site_protocol VARCHAR2(32) NOT NULL,
688 site_domain VARCHAR2(255) NOT NULL,
689 site_data BLOB NOT NULL,
690 site_forward NUMBER(1) NOT NULL,
691 site_config BLOB NOT NULL
693 ALTER TABLE &mw_prefix.sites ADD CONSTRAINT &mw_prefix.sites_pk PRIMARY KEY (site_id);
694 CREATE UNIQUE INDEX &mw_prefix.sites_u01 ON &mw_prefix.sites (site_global_key);
695 CREATE INDEX &mw_prefix.sites_i01 ON &mw_prefix.sites (site_type);
696 CREATE INDEX &mw_prefix.sites_i02 ON &mw_prefix.sites (site_group);
697 CREATE INDEX &mw_prefix.sites_i03 ON &mw_prefix.sites (site_source);
698 CREATE INDEX &mw_prefix.sites_i04 ON &mw_prefix.sites (site_language);
699 CREATE INDEX &mw_prefix.sites_i05 ON &mw_prefix.sites (site_protocol);
700 CREATE INDEX &mw_prefix.sites_i06 ON &mw_prefix.sites (site_domain);
701 CREATE INDEX &mw_prefix.sites_i07 ON &mw_prefix.sites (site_forward);
703 CREATE TABLE &mw_prefix.site_identifiers (
704 si_site NUMBER NOT NULL,
705 si_type VARCHAR2(32) NOT NULL,
706 si_key VARCHAR2(32) NOT NULL
708 CREATE UNIQUE INDEX &mw_prefix.site_identifiers_u01 ON &mw_prefix.site_identifiers (si_type, si_key);
709 CREATE INDEX &mw_prefix.site_identifiers_i01 ON &mw_prefix.site_identifiers (si_site);
710 CREATE INDEX &mw_prefix.site_identifiers_i02 ON &mw_prefix.site_identifiers (si_key);
712 -- do not prefix this table as it breaks parserTests
713 CREATE TABLE wiki_field_info_full (
714 table_name VARCHAR2(35) NOT NULL,
715 column_name VARCHAR2(35) NOT NULL,
716 data_default VARCHAR2(4000),
717 data_length NUMBER NOT NULL,
718 data_type VARCHAR2(106),
719 not_null CHAR(1) NOT NULL,
724 ALTER TABLE wiki_field_info_full ADD CONSTRAINT wiki_field_info_full_pk PRIMARY KEY (table_name, column_name);
727 CREATE PROCEDURE fill_wiki_info IS
729 DELETE wiki_field_info_full;
731 FOR x_rec IN (SELECT t.table_name table_name, t.column_name,
732 t.data_default, t.data_length, t.data_type,
733 DECODE (t.nullable, 'Y', '1', 'N', '0') not_null,
735 FROM user_cons_columns ucc,
737 WHERE ucc.table_name = t.table_name
738 AND ucc.column_name = t.column_name
739 AND uc.constraint_name = ucc.constraint_name
740 AND uc.constraint_type = 'P'
741 AND ROWNUM < 2) prim,
743 FROM user_ind_columns uic,
745 WHERE uic.table_name = t.table_name
746 AND uic.column_name = t.column_name
747 AND ui.index_name = uic.index_name
748 AND ui.uniqueness = 'UNIQUE'
749 AND ROWNUM < 2) uniq,
751 FROM user_ind_columns uic,
753 WHERE uic.table_name = t.table_name
754 AND uic.column_name = t.column_name
755 AND ui.index_name = uic.index_name
756 AND ui.uniqueness = 'NONUNIQUE'
757 AND ROWNUM < 2) nonuniq
758 FROM user_tab_columns t, user_tables ut
759 WHERE ut.table_name = t.table_name)
761 INSERT INTO wiki_field_info_full
762 (table_name, column_name,
763 data_default, data_length,
764 data_type, not_null, prim,
767 VALUES (x_rec.table_name, x_rec.column_name,
768 x_rec.data_default, x_rec.data_length,
769 x_rec.data_type, x_rec.not_null, x_rec.prim,
770 x_rec.uniq, x_rec.nonuniq
778 CREATE OR REPLACE PROCEDURE duplicate_table(p_tabname IN VARCHAR2,
779 p_oldprefix IN VARCHAR2,
780 p_newprefix IN VARCHAR2,
781 p_temporary IN BOOLEAN) IS
782 e_table_not_exist EXCEPTION;
783 PRAGMA EXCEPTION_INIT(e_table_not_exist, -00942);
784 l_temp_ei_sql VARCHAR2(2000);
785 l_temporary BOOLEAN := p_temporary;
788 EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname ||
789 ' CASCADE CONSTRAINTS PURGE';
791 WHEN e_table_not_exist THEN
794 IF (p_tabname = 'SEARCHINDEX') THEN
795 l_temporary := FALSE;
797 IF (l_temporary) THEN
798 EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix ||
800 ' ON COMMIT PRESERVE ROWS AS SELECT * FROM ' ||
801 p_oldprefix || p_tabname || ' WHERE ROWNUM = 0';
803 EXECUTE IMMEDIATE 'CREATE TABLE ' || p_newprefix || p_tabname ||
804 ' AS SELECT * FROM ' || p_oldprefix || p_tabname ||
807 FOR rc IN (SELECT column_name, data_default
808 FROM user_tab_columns
809 WHERE table_name = p_oldprefix || p_tabname
810 AND data_default IS NOT NULL) LOOP
811 EXECUTE IMMEDIATE 'ALTER TABLE ' || p_newprefix || p_tabname ||
812 ' MODIFY ' || rc.column_name || ' DEFAULT ' ||
813 SUBSTR(rc.data_default, 1, 2000);
815 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('CONSTRAINT',
819 USER || '"."' || p_oldprefix,
820 USER || '"."' || p_newprefix),
821 '"' || constraint_name || '"',
822 '"' || p_newprefix || constraint_name || '"') DDLVC2,
824 FROM user_constraints uc
825 WHERE table_name = p_oldprefix || p_tabname
826 AND constraint_type = 'P') LOOP
827 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
828 l_temp_ei_sql := SUBSTR(l_temp_ei_sql,
832 INSTR(l_temp_ei_sql, 'PRIMARY KEY') + 1) + 1);
833 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
834 EXECUTE IMMEDIATE l_temp_ei_sql;
837 IF (NOT l_temporary) THEN
838 FOR rc IN (SELECT REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('REF_CONSTRAINT',
842 USER || '"."' || p_oldprefix,
843 USER || '"."' || p_newprefix) DDLVC2,
845 FROM user_constraints uc
846 WHERE table_name = p_oldprefix || p_tabname
847 AND constraint_type = 'R') LOOP
848 IF nvl(length(l_temp_ei_sql), 0) > 0 AND
849 INSTR(l_temp_ei_sql, 'PRIMARY KEY') = 0 THEN
850 EXECUTE IMMEDIATE l_temp_ei_sql;
854 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
858 USER || '"."' || p_oldprefix,
859 USER || '"."' || p_newprefix),
860 '"' || index_name || '"',
861 '"' || p_newprefix || index_name || '"') DDLVC2,
865 WHERE table_name = p_oldprefix || p_tabname
866 AND index_type NOT IN ('LOB', 'DOMAIN')
869 FROM user_constraints
870 WHERE table_name = ui.table_name
871 AND constraint_name = ui.index_name)) LOOP
872 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
873 l_temp_ei_sql := SUBSTR(l_temp_ei_sql,
878 '"' || USER || '"."' || p_newprefix || '"') + 1) + 1);
879 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
880 EXECUTE IMMEDIATE l_temp_ei_sql;
883 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
887 USER || '"."' || p_oldprefix,
888 USER || '"."' || p_newprefix),
889 '"' || index_name || '"',
890 '"' || p_newprefix || index_name || '"') DDLVC2,
894 WHERE table_name = p_oldprefix || p_tabname
895 AND index_type = 'DOMAIN'
898 FROM user_constraints
899 WHERE table_name = ui.table_name
900 AND constraint_name = ui.index_name)) LOOP
901 l_temp_ei_sql := rc.ddlvc2;
902 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
903 EXECUTE IMMEDIATE l_temp_ei_sql;
906 FOR rc IN (SELECT REPLACE(REPLACE(UPPER(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('TRIGGER',
910 USER || '"."' || p_oldprefix,
911 USER || '"."' || p_newprefix),
912 ' ON ' || p_oldprefix || p_tabname,
913 ' ON ' || p_newprefix || p_tabname) DDLVC2,
916 WHERE table_name = p_oldprefix || p_tabname) LOOP
917 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'ALTER ') - 1);
918 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
919 EXECUTE IMMEDIATE l_temp_ei_sql;
927 CREATE OR REPLACE FUNCTION BITOR (x IN NUMBER, y IN NUMBER) RETURN NUMBER AS
929 RETURN (x + y - BITAND(x, y));
934 CREATE OR REPLACE FUNCTION BITNOT (x IN NUMBER) RETURN NUMBER AS
936 RETURN (4294967295 - x);
940 CREATE OR REPLACE TYPE GET_OUTPUT_TYPE IS TABLE OF VARCHAR2(255);
943 CREATE OR REPLACE FUNCTION GET_OUTPUT_LINES RETURN GET_OUTPUT_TYPE PIPELINED AS
944 v_line VARCHAR2(255);
945 v_status INTEGER := 0;
949 DBMS_OUTPUT.GET_LINE(v_line, v_status);
950 IF (v_status = 0) THEN RETURN; END IF;
961 CREATE OR REPLACE FUNCTION GET_SEQUENCE_VALUE(seq IN VARCHAR2) RETURN NUMBER AS
964 EXECUTE IMMEDIATE 'SELECT '||seq||'.NEXTVAL INTO :outVar FROM DUAL' INTO v_value;