1 -- defines must comply with ^define\s*([^\s=]*)\s*=\s?'\{\$([^\}]*)\}';
2 define mw_prefix
='{$wgDBprefix}';
5 CREATE SEQUENCE user_user_id_seq
MINVALUE 0 START WITH 0;
6 CREATE TABLE &mw_prefix.
mwuser ( -- replace reserved word 'user'
7 user_id
NUMBER NOT NULL,
8 user_name
VARCHAR2(255) NOT NULL,
9 user_real_name
VARCHAR2(512),
10 user_password
VARCHAR2(255),
11 user_newpassword
VARCHAR2(255),
12 user_newpass_time
TIMESTAMP(6) WITH TIME ZONE,
13 user_token
VARCHAR2(32),
14 user_email
VARCHAR2(255),
15 user_email_token
VARCHAR2(32),
16 user_email_token_expires
TIMESTAMP(6) WITH TIME ZONE,
17 user_email_authenticated
TIMESTAMP(6) WITH TIME ZONE,
19 user_touched
TIMESTAMP(6) WITH TIME ZONE,
20 user_registration
TIMESTAMP(6) WITH TIME ZONE,
23 ALTER TABLE &mw_prefix.mwuser
ADD CONSTRAINT &mw_prefix.mwuser_pk
PRIMARY KEY (user_id
);
24 CREATE UNIQUE INDEX &mw_prefix.mwuser_u01
ON &mw_prefix.
mwuser (user_name
);
25 CREATE INDEX &mw_prefix.mwuser_i01
ON &mw_prefix.
mwuser (user_email_token
);
26 CREATE INDEX &mw_prefix.mwuser_i02
ON &mw_prefix.
mwuser (user_email
, user_name
);
28 -- Create a dummy user to satisfy fk contraints especially with revisions
29 INSERT INTO &mw_prefix.mwuser
30 VALUES (user_user_id_seq.nextval
,'Anonymous',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, '', current_timestamp, current_timestamp, 0);
32 CREATE TABLE &mw_prefix.
user_groups (
33 ug_user
NUMBER DEFAULT 0 NOT NULL,
34 ug_group
VARCHAR2(32) NOT NULL
36 ALTER TABLE &mw_prefix.user_groups
ADD CONSTRAINT &mw_prefix.user_groups_fk1
FOREIGN KEY (ug_user
) REFERENCES &mw_prefix.
mwuser(user_id
) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
37 CREATE UNIQUE INDEX &mw_prefix.user_groups_u01
ON &mw_prefix.
user_groups (ug_user
,ug_group
);
38 CREATE INDEX &mw_prefix.user_groups_i01
ON &mw_prefix.
user_groups (ug_group
);
40 CREATE TABLE &mw_prefix.
user_former_groups (
41 ufg_user
NUMBER DEFAULT 0 NOT NULL,
42 ufg_group
VARCHAR2(16) NOT NULL
44 ALTER TABLE &mw_prefix.user_former_groups
ADD CONSTRAINT &mw_prefix.user_former_groups_fk1
FOREIGN KEY (ufg_user
) REFERENCES &mw_prefix.
mwuser(user_id
) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
45 CREATE UNIQUE INDEX &mw_prefix.user_former_groups_u01
ON &mw_prefix.
user_former_groups (ufg_user
,ufg_group
);
47 CREATE TABLE &mw_prefix.
user_newtalk (
48 user_id
NUMBER DEFAULT 0 NOT NULL,
49 user_ip
VARCHAR2(40) NULL,
50 user_last_timestamp
TIMESTAMP(6) WITH TIME ZONE
52 ALTER TABLE &mw_prefix.user_newtalk
ADD CONSTRAINT &mw_prefix.user_newtalk_fk1
FOREIGN KEY (user_id
) REFERENCES &mw_prefix.
mwuser(user_id
) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
53 CREATE INDEX &mw_prefix.user_newtalk_i01
ON &mw_prefix.
user_newtalk (user_id
);
54 CREATE INDEX &mw_prefix.user_newtalk_i02
ON &mw_prefix.
user_newtalk (user_ip
);
56 CREATE TABLE &mw_prefix.
user_properties (
57 up_user
NUMBER NOT NULL,
58 up_property
VARCHAR2(255) NOT NULL,
61 CREATE UNIQUE INDEX &mw_prefix.user_properties_u01
on &mw_prefix.
user_properties (up_user
,up_property
);
62 CREATE INDEX &mw_prefix.user_properties_i01
on &mw_prefix.
user_properties (up_property
);
64 CREATE SEQUENCE page_page_id_seq
;
65 CREATE TABLE &mw_prefix.
page (
66 page_id
NUMBER NOT NULL,
67 page_namespace
NUMBER DEFAULT 0 NOT NULL,
68 page_title
VARCHAR2(255) NOT NULL,
69 page_restrictions
VARCHAR2(255),
70 page_counter
NUMBER DEFAULT 0 NOT NULL,
71 page_is_redirect
CHAR(1) DEFAULT '0' NOT NULL,
72 page_is_new
CHAR(1) DEFAULT '0' NOT NULL,
73 page_random
NUMBER(15,14) NOT NULL,
74 page_touched
TIMESTAMP(6) WITH TIME ZONE,
75 page_latest
NUMBER DEFAULT 0 NOT NULL, -- FK?
76 page_len
NUMBER DEFAULT 0 NOT NULL
78 ALTER TABLE &mw_prefix.page
ADD CONSTRAINT &mw_prefix.page_pk
PRIMARY KEY (page_id
);
79 CREATE UNIQUE INDEX &mw_prefix.page_u01
ON &mw_prefix.
page (page_namespace
,page_title
);
80 CREATE INDEX &mw_prefix.page_i01
ON &mw_prefix.
page (page_random
);
81 CREATE INDEX &mw_prefix.page_i02
ON &mw_prefix.
page (page_len
);
82 CREATE INDEX &mw_prefix.page_i03
ON &mw_prefix.
page (page_is_redirect
, page_namespace
, page_len
);
84 -- Create a dummy page to satisfy fk contraints especially with revisions
85 INSERT INTO &mw_prefix.page
86 VALUES (0, 0, ' ', NULL, 0, 0, 0, 0, current_timestamp, 0, 0);
89 CREATE TRIGGER &mw_prefix.page_set_random
BEFORE INSERT ON &mw_prefix.page
90 FOR EACH ROW WHEN (new.page_random
IS NULL)
92 SELECT dbms_random.
value INTO :NEW.page_random
FROM dual
;
96 CREATE SEQUENCE revision_rev_id_seq
;
97 CREATE TABLE &mw_prefix.
revision (
98 rev_id
NUMBER NOT NULL,
99 rev_page
NUMBER NOT NULL,
100 rev_text_id
NUMBER NULL,
101 rev_comment
VARCHAR2(255),
102 rev_user
NUMBER DEFAULT 0 NOT NULL,
103 rev_user_text
VARCHAR2(255) NOT NULL,
104 rev_timestamp
TIMESTAMP(6) WITH TIME ZONE NOT NULL,
105 rev_minor_edit
CHAR(1) DEFAULT '0' NOT NULL,
106 rev_deleted
CHAR(1) DEFAULT '0' NOT NULL,
108 rev_parent_id
NUMBER DEFAULT NULL,
109 rev_sha1
VARCHAR2(32) NULL
111 ALTER TABLE &mw_prefix.revision
ADD CONSTRAINT &mw_prefix.revision_pk
PRIMARY KEY (rev_id
);
112 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;
113 ALTER TABLE &mw_prefix.revision
ADD CONSTRAINT &mw_prefix.revision_fk2
FOREIGN KEY (rev_user
) REFERENCES &mw_prefix.
mwuser(user_id
) DEFERRABLE INITIALLY DEFERRED;
114 CREATE UNIQUE INDEX &mw_prefix.revision_u01
ON &mw_prefix.
revision (rev_page
, rev_id
);
115 CREATE INDEX &mw_prefix.revision_i01
ON &mw_prefix.
revision (rev_timestamp
);
116 CREATE INDEX &mw_prefix.revision_i02
ON &mw_prefix.
revision (rev_page
,rev_timestamp
);
117 CREATE INDEX &mw_prefix.revision_i03
ON &mw_prefix.
revision (rev_user
,rev_timestamp
);
118 CREATE INDEX &mw_prefix.revision_i04
ON &mw_prefix.
revision (rev_user_text
,rev_timestamp
);
120 CREATE SEQUENCE text_old_id_seq
;
121 CREATE TABLE &mw_prefix.
pagecontent ( -- replaces reserved word 'text'
122 old_id
NUMBER NOT NULL,
124 old_flags
VARCHAR2(255)
126 ALTER TABLE &mw_prefix.pagecontent
ADD CONSTRAINT &mw_prefix.pagecontent_pk
PRIMARY KEY (old_id
);
128 CREATE TABLE &mw_prefix.
archive (
129 ar_namespace
NUMBER DEFAULT 0 NOT NULL,
130 ar_title
VARCHAR2(255) NOT NULL,
132 ar_comment
VARCHAR2(255),
133 ar_user
NUMBER DEFAULT 0 NOT NULL,
134 ar_user_text
VARCHAR2(255) NOT NULL,
135 ar_timestamp
TIMESTAMP(6) WITH TIME ZONE NOT NULL,
136 ar_minor_edit
CHAR(1) DEFAULT '0' NOT NULL,
137 ar_flags
VARCHAR2(255),
140 ar_deleted
CHAR(1) DEFAULT '0' NOT NULL,
144 ar_sha1
VARCHAR2(32) NULL
146 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;
147 CREATE INDEX &mw_prefix.archive_i01
ON &mw_prefix.
archive (ar_namespace
,ar_title
,ar_timestamp
);
148 CREATE INDEX &mw_prefix.archive_i02
ON &mw_prefix.
archive (ar_user_text
,ar_timestamp
);
149 CREATE INDEX &mw_prefix.archive_i03
ON &mw_prefix.
archive (ar_rev_id
);
151 CREATE TABLE &mw_prefix.
pagelinks (
152 pl_from
NUMBER NOT NULL,
153 pl_namespace
NUMBER DEFAULT 0 NOT NULL,
154 pl_title
VARCHAR2(255) NOT NULL
156 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;
157 CREATE UNIQUE INDEX &mw_prefix.pagelinks_u01
ON &mw_prefix.
pagelinks (pl_from
,pl_namespace
,pl_title
);
158 CREATE UNIQUE INDEX &mw_prefix.pagelinks_u02
ON &mw_prefix.
pagelinks (pl_namespace
,pl_title
,pl_from
);
160 CREATE TABLE &mw_prefix.
templatelinks (
161 tl_from
NUMBER NOT NULL,
162 tl_namespace
NUMBER DEFAULT 0 NOT NULL,
163 tl_title
VARCHAR2(255) NOT NULL
165 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;
166 CREATE UNIQUE INDEX &mw_prefix.templatelinks_u01
ON &mw_prefix.
templatelinks (tl_from
,tl_namespace
,tl_title
);
167 CREATE UNIQUE INDEX &mw_prefix.templatelinks_u02
ON &mw_prefix.
templatelinks (tl_namespace
,tl_title
,tl_from
);
169 CREATE TABLE &mw_prefix.
imagelinks (
170 il_from
NUMBER NOT NULL,
171 il_to
VARCHAR2(255) NOT NULL
173 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;
174 CREATE UNIQUE INDEX &mw_prefix.imagelinks_u01
ON &mw_prefix.
imagelinks (il_from
,il_to
);
175 CREATE UNIQUE INDEX &mw_prefix.imagelinks_u02
ON &mw_prefix.
imagelinks (il_to
,il_from
);
178 CREATE TABLE &mw_prefix.
categorylinks (
179 cl_from
NUMBER NOT NULL,
180 cl_to
VARCHAR2(255) NOT NULL,
181 cl_sortkey
VARCHAR2(230),
182 cl_sortkey_prefix
VARCHAR2(255),
183 cl_timestamp
TIMESTAMP(6) WITH TIME ZONE NOT NULL,
184 cl_collation
VARCHAR2(32),
185 cl_type
VARCHAR2(6) DEFAULT 'page' NOT NULL
187 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;
188 CREATE UNIQUE INDEX &mw_prefix.categorylinks_u01
ON &mw_prefix.
categorylinks (cl_from
,cl_to
);
189 CREATE INDEX &mw_prefix.categorylinks_i01
ON &mw_prefix.
categorylinks (cl_to
,cl_type
,cl_sortkey
,cl_from
);
190 CREATE INDEX &mw_prefix.categorylinks_i02
ON &mw_prefix.
categorylinks (cl_to
,cl_timestamp
);
191 CREATE INDEX &mw_prefix.categorylinks_i03
ON &mw_prefix.
categorylinks (cl_collation
);
193 CREATE SEQUENCE category_cat_id_seq
;
194 CREATE TABLE &mw_prefix.
category (
195 cat_id
NUMBER NOT NULL,
196 cat_title
VARCHAR2(255) NOT NULL,
197 cat_pages
NUMBER DEFAULT 0 NOT NULL,
198 cat_subcats
NUMBER DEFAULT 0 NOT NULL,
199 cat_files
NUMBER DEFAULT 0 NOT NULL,
200 cat_hidden
NUMBER DEFAULT 0 NOT NULL
202 ALTER TABLE &mw_prefix.category
ADD CONSTRAINT &mw_prefix.category_pk
PRIMARY KEY (cat_id
);
203 CREATE UNIQUE INDEX &mw_prefix.category_u01
ON &mw_prefix.
category (cat_title
);
204 CREATE INDEX &mw_prefix.category_i01
ON &mw_prefix.
category (cat_pages
);
206 CREATE TABLE &mw_prefix.
externallinks (
207 el_from
NUMBER NOT NULL,
208 el_to
VARCHAR2(2048) NOT NULL,
209 el_index
VARCHAR2(2048) NOT NULL
211 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;
212 CREATE INDEX &mw_prefix.externallinks_i01
ON &mw_prefix.
externallinks (el_from
, el_to
);
213 CREATE INDEX &mw_prefix.externallinks_i02
ON &mw_prefix.
externallinks (el_to
, el_from
);
214 CREATE INDEX &mw_prefix.externallinks_i03
ON &mw_prefix.
externallinks (el_index
);
216 CREATE TABLE &mw_prefix.
external_user (
217 eu_local_id
NUMBER NOT NULL,
218 eu_external_id
varchar2(255) NOT NULL
220 ALTER TABLE &mw_prefix.external_user
ADD CONSTRAINT &mw_prefix.external_user_pk
PRIMARY KEY (eu_local_id
);
221 CREATE UNIQUE INDEX &mw_prefix.external_user_u01
ON &mw_prefix.
external_user (eu_external_id
);
223 CREATE TABLE &mw_prefix.
langlinks (
224 ll_from
NUMBER NOT NULL,
225 ll_lang
VARCHAR2(20),
226 ll_title
VARCHAR2(255)
228 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;
229 CREATE UNIQUE INDEX &mw_prefix.langlinks_u01
ON &mw_prefix.
langlinks (ll_from
, ll_lang
);
230 CREATE INDEX &mw_prefix.langlinks_i01
ON &mw_prefix.
langlinks (ll_lang
, ll_title
);
232 CREATE TABLE &mw_prefix.
iwlinks (
233 iwl_from
NUMBER DEFAULT 0 NOT NULL,
234 iwl_prefix
VARCHAR2(20),
235 iwl_title
VARCHAR2(255)
237 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui01
ON &mw_prefix.
iwlinks (iwl_from
, iwl_prefix
, iwl_title
);
238 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui02
ON &mw_prefix.
iwlinks (iwl_prefix
, iwl_title
, iwl_from
);
240 CREATE TABLE &mw_prefix.
site_stats (
241 ss_row_id
NUMBER NOT NULL ,
242 ss_total_views
NUMBER DEFAULT 0,
243 ss_total_edits
NUMBER DEFAULT 0,
244 ss_good_articles
NUMBER DEFAULT 0,
245 ss_total_pages
NUMBER DEFAULT -1,
246 ss_users
NUMBER DEFAULT -1,
247 ss_active_users
NUMBER DEFAULT -1,
248 ss_admins
NUMBER DEFAULT -1,
249 ss_images
NUMBER DEFAULT 0
251 CREATE UNIQUE INDEX &mw_prefix.site_stats_u01
ON &mw_prefix.
site_stats (ss_row_id
);
253 CREATE TABLE &mw_prefix.
hitcounter (
254 hc_id
NUMBER NOT NULL
257 CREATE SEQUENCE ipblocks_ipb_id_seq
;
258 CREATE TABLE &mw_prefix.
ipblocks (
259 ipb_id
NUMBER NOT NULL,
260 ipb_address
VARCHAR2(255) NULL,
261 ipb_user
NUMBER DEFAULT 0 NOT NULL,
262 ipb_by
NUMBER DEFAULT 0 NOT NULL,
263 ipb_by_text
VARCHAR2(255) NULL,
264 ipb_reason
VARCHAR2(255) NOT NULL,
265 ipb_timestamp
TIMESTAMP(6) WITH TIME ZONE NOT NULL,
266 ipb_auto
CHAR(1) DEFAULT '0' NOT NULL,
267 ipb_anon_only
CHAR(1) DEFAULT '0' NOT NULL,
268 ipb_create_account
CHAR(1) DEFAULT '1' NOT NULL,
269 ipb_enable_autoblock
CHAR(1) DEFAULT '1' NOT NULL,
270 ipb_expiry
TIMESTAMP(6) WITH TIME ZONE NOT NULL,
271 ipb_range_start
VARCHAR2(255),
272 ipb_range_end
VARCHAR2(255),
273 ipb_deleted
CHAR(1) DEFAULT '0' NOT NULL,
274 ipb_block_email
CHAR(1) DEFAULT '0' NOT NULL,
275 ipb_allow_usertalk
CHAR(1) DEFAULT '0' NOT NULL
277 ALTER TABLE &mw_prefix.ipblocks
ADD CONSTRAINT &mw_prefix.ipblocks_pk
PRIMARY KEY (ipb_id
);
278 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;
279 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;
280 CREATE UNIQUE INDEX &mw_prefix.ipblocks_u01
ON &mw_prefix.
ipblocks (ipb_address
, ipb_user
, ipb_auto
, ipb_anon_only
);
281 CREATE INDEX &mw_prefix.ipblocks_i01
ON &mw_prefix.
ipblocks (ipb_user
);
282 CREATE INDEX &mw_prefix.ipblocks_i02
ON &mw_prefix.
ipblocks (ipb_range_start
, ipb_range_end
);
283 CREATE INDEX &mw_prefix.ipblocks_i03
ON &mw_prefix.
ipblocks (ipb_timestamp
);
284 CREATE INDEX &mw_prefix.ipblocks_i04
ON &mw_prefix.
ipblocks (ipb_expiry
);
286 CREATE TABLE &mw_prefix.
image (
287 img_name
VARCHAR2(255) NOT NULL,
288 img_size
NUMBER DEFAULT 0 NOT NULL,
289 img_width
NUMBER DEFAULT 0 NOT NULL,
290 img_height
NUMBER DEFAULT 0 NOT NULL,
292 img_bits
NUMBER DEFAULT 0 NOT NULL,
293 img_media_type
VARCHAR2(32),
294 img_major_mime
VARCHAR2(32) DEFAULT 'unknown',
295 img_minor_mime
VARCHAR2(100) DEFAULT 'unknown',
296 img_description
VARCHAR2(255),
297 img_user
NUMBER DEFAULT 0 NOT NULL,
298 img_user_text
VARCHAR2(255) NOT NULL,
299 img_timestamp
TIMESTAMP(6) WITH TIME ZONE,
300 img_sha1
VARCHAR2(32)
302 ALTER TABLE &mw_prefix.image
ADD CONSTRAINT &mw_prefix.image_pk
PRIMARY KEY (img_name
);
303 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;
304 CREATE INDEX &mw_prefix.image_i01
ON &mw_prefix.
image (img_user_text
,img_timestamp
);
305 CREATE INDEX &mw_prefix.image_i02
ON &mw_prefix.
image (img_size
);
306 CREATE INDEX &mw_prefix.image_i03
ON &mw_prefix.
image (img_timestamp
);
307 CREATE INDEX &mw_prefix.image_i04
ON &mw_prefix.
image (img_sha1
);
310 CREATE TABLE &mw_prefix.
oldimage (
311 oi_name
VARCHAR2(255) DEFAULT 0 NOT NULL,
312 oi_archive_name
VARCHAR2(255),
313 oi_size
NUMBER DEFAULT 0 NOT NULL,
314 oi_width
NUMBER DEFAULT 0 NOT NULL,
315 oi_height
NUMBER DEFAULT 0 NOT NULL,
316 oi_bits
NUMBER DEFAULT 0 NOT NULL,
317 oi_description
VARCHAR2(255),
318 oi_user
NUMBER DEFAULT 0 NOT NULL,
319 oi_user_text
VARCHAR2(255) NOT NULL,
320 oi_timestamp
TIMESTAMP(6) WITH TIME ZONE NOT NULL,
322 oi_media_type
VARCHAR2(32) DEFAULT NULL,
323 oi_major_mime
VARCHAR2(32) DEFAULT 'unknown',
324 oi_minor_mime
VARCHAR2(100) DEFAULT 'unknown',
325 oi_deleted
NUMBER DEFAULT 0 NOT NULL,
328 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;
329 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;
330 CREATE INDEX &mw_prefix.oldimage_i01
ON &mw_prefix.
oldimage (oi_user_text
,oi_timestamp
);
331 CREATE INDEX &mw_prefix.oldimage_i02
ON &mw_prefix.
oldimage (oi_name
,oi_timestamp
);
332 CREATE INDEX &mw_prefix.oldimage_i03
ON &mw_prefix.
oldimage (oi_name
,oi_archive_name
);
333 CREATE INDEX &mw_prefix.oldimage_i04
ON &mw_prefix.
oldimage (oi_sha1
);
336 CREATE SEQUENCE filearchive_fa_id_seq
;
337 CREATE TABLE &mw_prefix.
filearchive (
338 fa_id
NUMBER NOT NULL,
339 fa_name
VARCHAR2(255) NOT NULL,
340 fa_archive_name
VARCHAR2(255),
341 fa_storage_group
VARCHAR2(16),
342 fa_storage_key
VARCHAR2(64),
343 fa_deleted_user
NUMBER DEFAULT 0 NOT NULL,
344 fa_deleted_timestamp
TIMESTAMP(6) WITH TIME ZONE NOT NULL,
345 fa_deleted_reason
CLOB,
346 fa_size
NUMBER DEFAULT 0 NOT NULL,
347 fa_width
NUMBER DEFAULT 0 NOT NULL,
348 fa_height
NUMBER DEFAULT 0 NOT NULL,
350 fa_bits
NUMBER DEFAULT 0 NOT NULL,
351 fa_media_type
VARCHAR2(32) DEFAULT NULL,
352 fa_major_mime
VARCHAR2(32) DEFAULT 'unknown',
353 fa_minor_mime
VARCHAR2(100) DEFAULT 'unknown',
354 fa_description
VARCHAR2(255),
355 fa_user
NUMBER DEFAULT 0 NOT NULL,
356 fa_user_text
VARCHAR2(255) NOT NULL,
357 fa_timestamp
TIMESTAMP(6) WITH TIME ZONE,
358 fa_deleted
NUMBER DEFAULT 0 NOT NULL
360 ALTER TABLE &mw_prefix.filearchive
ADD CONSTRAINT &mw_prefix.filearchive_pk
PRIMARY KEY (fa_id
);
361 ALTER TABLE &mw_prefix.filearchive
ADD CONSTRAINT &mw_prefix.filearchive_fk1
FOREIGN KEY (fa_deleted_user
) REFERENCES &mw_prefix.
mwuser(user_id
) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
362 ALTER TABLE &mw_prefix.filearchive
ADD CONSTRAINT &mw_prefix.filearchive_fk2
FOREIGN KEY (fa_user
) REFERENCES &mw_prefix.
mwuser(user_id
) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
363 CREATE INDEX &mw_prefix.filearchive_i01
ON &mw_prefix.
filearchive (fa_name
, fa_timestamp
);
364 CREATE INDEX &mw_prefix.filearchive_i02
ON &mw_prefix.
filearchive (fa_storage_group
, fa_storage_key
);
365 CREATE INDEX &mw_prefix.filearchive_i03
ON &mw_prefix.
filearchive (fa_deleted_timestamp
);
366 CREATE INDEX &mw_prefix.filearchive_i04
ON &mw_prefix.
filearchive (fa_user_text
,fa_timestamp
);
368 CREATE SEQUENCE uploadstash_us_id_seq
;
369 CREATE TABLE &mw_prefix.
uploadstash (
370 us_id
NUMBER NOT NULL,
371 us_user
NUMBER DEFAULT 0 NOT NULL,
372 us_key
VARCHAR2(255) NOT NULL,
373 us_orig_path
VARCHAR2(255) NOT NULL,
374 us_path
VARCHAR2(255) NOT NULL,
375 us_source_type
VARCHAR2(50),
376 us_timestamp
TIMESTAMP(6) WITH TIME ZONE,
377 us_status
VARCHAR2(50) NOT NULL,
379 us_size
NUMBER NOT NULL,
380 us_sha1
VARCHAR2(32) NOT NULL,
381 us_mime
VARCHAR2(255),
382 us_media_type
VARCHAR2(32) DEFAULT NULL,
383 us_image_width
NUMBER,
384 us_image_height
NUMBER,
387 ALTER TABLE &mw_prefix.uploadstash
ADD CONSTRAINT &mw_prefix.uploadstash_pk
PRIMARY KEY (us_id
);
388 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;
389 CREATE INDEX &mw_prefix.uploadstash_i01
ON &mw_prefix.
uploadstash (us_user
);
390 CREATE INDEX &mw_prefix.uploadstash_i02
ON &mw_prefix.
uploadstash (us_timestamp
);
391 CREATE UNIQUE INDEX &mw_prefix.uploadstash_u01
ON &mw_prefix.
uploadstash (us_key
);
393 CREATE SEQUENCE recentchanges_rc_id_seq
;
394 CREATE TABLE &mw_prefix.
recentchanges (
395 rc_id
NUMBER NOT NULL,
396 rc_timestamp
TIMESTAMP(6) WITH TIME ZONE NOT NULL,
397 rc_cur_time
TIMESTAMP(6) WITH TIME ZONE NOT NULL,
398 rc_user
NUMBER DEFAULT 0 NOT NULL,
399 rc_user_text
VARCHAR2(255) NOT NULL,
400 rc_namespace
NUMBER DEFAULT 0 NOT NULL,
401 rc_title
VARCHAR2(255) NOT NULL,
402 rc_comment
VARCHAR2(255),
403 rc_minor
CHAR(1) DEFAULT '0' NOT NULL,
404 rc_bot
CHAR(1) DEFAULT '0' NOT NULL,
405 rc_new
CHAR(1) DEFAULT '0' NOT NULL,
406 rc_cur_id
NUMBER DEFAULT 0 NOT NULL,
407 rc_this_oldid
NUMBER DEFAULT 0 NOT NULL,
408 rc_last_oldid
NUMBER DEFAULT 0 NOT NULL,
409 rc_type
CHAR(1) DEFAULT '0' NOT NULL,
410 rc_moved_to_ns
NUMBER DEFAULT 0 NOT NULL,
411 rc_moved_to_title
VARCHAR2(255),
412 rc_patrolled
CHAR(1) DEFAULT '0' NOT NULL,
416 rc_deleted
CHAR(1) DEFAULT '0' NOT NULL,
417 rc_logid
NUMBER DEFAULT 0 NOT NULL,
418 rc_log_type
VARCHAR2(255),
419 rc_log_action
VARCHAR2(255),
422 ALTER TABLE &mw_prefix.recentchanges
ADD CONSTRAINT &mw_prefix.recentchanges_pk
PRIMARY KEY (rc_id
);
423 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;
424 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;
425 CREATE INDEX &mw_prefix.recentchanges_i01
ON &mw_prefix.
recentchanges (rc_timestamp
);
426 CREATE INDEX &mw_prefix.recentchanges_i02
ON &mw_prefix.
recentchanges (rc_namespace
, rc_title
);
427 CREATE INDEX &mw_prefix.recentchanges_i03
ON &mw_prefix.
recentchanges (rc_cur_id
);
428 CREATE INDEX &mw_prefix.recentchanges_i04
ON &mw_prefix.
recentchanges (rc_new
,rc_namespace
,rc_timestamp
);
429 CREATE INDEX &mw_prefix.recentchanges_i05
ON &mw_prefix.
recentchanges (rc_ip
);
430 CREATE INDEX &mw_prefix.recentchanges_i06
ON &mw_prefix.
recentchanges (rc_namespace
, rc_user_text
);
431 CREATE INDEX &mw_prefix.recentchanges_i07
ON &mw_prefix.
recentchanges (rc_user_text
, rc_timestamp
);
433 CREATE TABLE &mw_prefix.
watchlist (
434 wl_user
NUMBER NOT NULL,
435 wl_namespace
NUMBER DEFAULT 0 NOT NULL,
436 wl_title
VARCHAR2(255) NOT NULL,
437 wl_notificationtimestamp
TIMESTAMP(6) WITH TIME ZONE
439 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;
440 CREATE UNIQUE INDEX &mw_prefix.watchlist_u01
ON &mw_prefix.
watchlist (wl_user
, wl_namespace
, wl_title
);
441 CREATE INDEX &mw_prefix.watchlist_i01
ON &mw_prefix.
watchlist (wl_namespace
, wl_title
);
444 CREATE TABLE &mw_prefix.
searchindex (
445 si_page
NUMBER NOT NULL,
446 si_title
VARCHAR2(255),
447 si_text
CLOB NOT NULL
449 CREATE UNIQUE INDEX &mw_prefix.searchindex_u01
ON &mw_prefix.
searchindex (si_page
);
451 CREATE TABLE &mw_prefix.
interwiki (
452 iw_prefix
VARCHAR2(32) NOT NULL,
453 iw_url
VARCHAR2(127) NOT NULL,
454 iw_api
BLOB NOT NULL,
455 iw_wikiid
VARCHAR2(64),
456 iw_local
CHAR(1) NOT NULL,
457 iw_trans
CHAR(1) DEFAULT '0' NOT NULL
459 CREATE UNIQUE INDEX &mw_prefix.interwiki_u01
ON &mw_prefix.
interwiki (iw_prefix
);
461 CREATE TABLE &mw_prefix.
querycache (
462 qc_type
VARCHAR2(32) NOT NULL,
463 qc_value
NUMBER DEFAULT 0 NOT NULL,
464 qc_namespace
NUMBER DEFAULT 0 NOT NULL,
465 qc_title
VARCHAR2(255) NOT NULL
467 CREATE INDEX &mw_prefix.querycache_u01
ON &mw_prefix.
querycache (qc_type
,qc_value
);
469 CREATE TABLE &mw_prefix.
objectcache (
470 keyname
VARCHAR2(255) ,
472 exptime
TIMESTAMP(6) WITH TIME ZONE NOT NULL
474 CREATE INDEX &mw_prefix.objectcache_i01
ON &mw_prefix.
objectcache (exptime
);
476 CREATE TABLE &mw_prefix.
transcache (
477 tc_url
VARCHAR2(255) NOT NULL,
478 tc_contents
CLOB NOT NULL,
479 tc_time
TIMESTAMP(6) WITH TIME ZONE NOT NULL
481 CREATE UNIQUE INDEX &mw_prefix.transcache_u01
ON &mw_prefix.
transcache (tc_url
);
484 CREATE SEQUENCE logging_log_id_seq
;
485 CREATE TABLE &mw_prefix.
logging (
486 log_id
NUMBER NOT NULL,
487 log_type
VARCHAR2(10) NOT NULL,
488 log_action
VARCHAR2(10) NOT NULL,
489 log_timestamp
TIMESTAMP(6) WITH TIME ZONE NOT NULL,
490 log_user
NUMBER DEFAULT 0 NOT NULL,
491 log_user_text
VARCHAR2(255),
492 log_namespace
NUMBER DEFAULT 0 NOT NULL,
493 log_title
VARCHAR2(255) NOT NULL,
495 log_comment
VARCHAR2(255),
497 log_deleted
CHAR(1) DEFAULT '0' NOT NULL
499 ALTER TABLE &mw_prefix.logging
ADD CONSTRAINT &mw_prefix.logging_pk
PRIMARY KEY (log_id
);
500 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;
501 CREATE INDEX &mw_prefix.logging_i01
ON &mw_prefix.
logging (log_type
, log_timestamp
);
502 CREATE INDEX &mw_prefix.logging_i02
ON &mw_prefix.
logging (log_user
, log_timestamp
);
503 CREATE INDEX &mw_prefix.logging_i03
ON &mw_prefix.
logging (log_namespace
, log_title
, log_timestamp
);
504 CREATE INDEX &mw_prefix.logging_i04
ON &mw_prefix.
logging (log_timestamp
);
505 CREATE INDEX &mw_prefix.logging_i05
ON &mw_prefix.
logging (log_type
, log_action
, log_timestamp
);
507 CREATE TABLE &mw_prefix.
log_search (
508 ls_field
VARCHAR2(32) NOT NULL,
509 ls_value
VARCHAR2(255) NOT NULL,
510 ls_log_id
NuMBER DEFAULT 0 NOT NULL
512 ALTER TABLE &mw_prefix.log_search
ADD CONSTRAINT log_search_pk
PRIMARY KEY (ls_field
,ls_value
,ls_log_id
);
513 CREATE INDEX &mw_prefix.log_search_i01
ON &mw_prefix.
log_search (ls_log_id
);
516 CREATE SEQUENCE job_job_id_seq
;
517 CREATE TABLE &mw_prefix.
job (
518 job_id
NUMBER NOT NULL,
519 job_cmd
VARCHAR2(60) NOT NULL,
520 job_namespace
NUMBER DEFAULT 0 NOT NULL,
521 job_title
VARCHAR2(255) NOT NULL,
522 job_timestamp
TIMESTAMP(6) WITH TIME ZONE NULL,
523 job_params
CLOB NOT NULL
525 ALTER TABLE &mw_prefix.job
ADD CONSTRAINT &mw_prefix.job_pk
PRIMARY KEY (job_id
);
526 CREATE INDEX &mw_prefix.job_i01
ON &mw_prefix.
job (job_cmd
, job_namespace
, job_title
);
527 CREATE INDEX &mw_prefix.job_i02
ON &mw_prefix.
job (job_timestamp
);
529 CREATE TABLE &mw_prefix.
querycache_info (
530 qci_type
VARCHAR2(32) NOT NULL,
531 qci_timestamp
TIMESTAMP(6) WITH TIME ZONE NULL
533 CREATE UNIQUE INDEX &mw_prefix.querycache_info_u01
ON &mw_prefix.
querycache_info (qci_type
);
535 CREATE TABLE &mw_prefix.
redirect (
536 rd_from
NUMBER NOT NULL,
537 rd_namespace
NUMBER DEFAULT 0 NOT NULL,
538 rd_title
VARCHAR2(255) NOT NULL,
539 rd_interwiki
VARCHAR2(32),
540 rd_fragment
VARCHAR2(255)
542 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;
543 CREATE INDEX &mw_prefix.redirect_i01
ON &mw_prefix.
redirect (rd_namespace
,rd_title
,rd_from
);
545 CREATE TABLE &mw_prefix.
querycachetwo (
546 qcc_type
VARCHAR2(32) NOT NULL,
547 qcc_value
NUMBER DEFAULT 0 NOT NULL,
548 qcc_namespace
NUMBER DEFAULT 0 NOT NULL,
549 qcc_title
VARCHAR2(255),
550 qcc_namespacetwo
NUMBER DEFAULT 0 NOT NULL,
551 qcc_titletwo
VARCHAR2(255)
553 CREATE INDEX &mw_prefix.querycachetwo_i01
ON &mw_prefix.
querycachetwo (qcc_type
,qcc_value
);
554 CREATE INDEX &mw_prefix.querycachetwo_i02
ON &mw_prefix.
querycachetwo (qcc_type
,qcc_namespace
,qcc_title
);
555 CREATE INDEX &mw_prefix.querycachetwo_i03
ON &mw_prefix.
querycachetwo (qcc_type
,qcc_namespacetwo
,qcc_titletwo
);
557 CREATE SEQUENCE page_restrictions_pr_id_seq
;
558 CREATE TABLE &mw_prefix.
page_restrictions (
559 pr_id
NUMBER NOT NULL,
560 pr_page
NUMBER NOT NULL,
561 pr_type
VARCHAR2(255) NOT NULL,
562 pr_level
VARCHAR2(255) NOT NULL,
563 pr_cascade
NUMBER NOT NULL,
565 pr_expiry
TIMESTAMP(6) WITH TIME ZONE NULL
567 ALTER TABLE &mw_prefix.page_restrictions
ADD CONSTRAINT &mw_prefix.page_restrictions_pk
PRIMARY KEY (pr_page
,pr_type
);
568 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;
569 CREATE INDEX &mw_prefix.page_restrictions_i01
ON &mw_prefix.
page_restrictions (pr_type
,pr_level
);
570 CREATE INDEX &mw_prefix.page_restrictions_i02
ON &mw_prefix.
page_restrictions (pr_level
);
571 CREATE INDEX &mw_prefix.page_restrictions_i03
ON &mw_prefix.
page_restrictions (pr_cascade
);
573 CREATE TABLE &mw_prefix.
protected_titles (
574 pt_namespace
NUMBER DEFAULT 0 NOT NULL,
575 pt_title
VARCHAR2(255) NOT NULL,
576 pt_user
NUMBER NOT NULL,
577 pt_reason
VARCHAR2(255),
578 pt_timestamp
TIMESTAMP(6) WITH TIME ZONE NOT NULL,
579 pt_expiry
VARCHAR2(14) NOT NULL,
580 pt_create_perm
VARCHAR2(60) NOT NULL
582 CREATE UNIQUE INDEX &mw_prefix.protected_titles_u01
ON &mw_prefix.
protected_titles (pt_namespace
,pt_title
);
583 CREATE INDEX &mw_prefix.protected_titles_i01
ON &mw_prefix.
protected_titles (pt_timestamp
);
585 CREATE TABLE &mw_prefix.
page_props (
586 pp_page
NUMBER NOT NULL,
587 pp_propname
VARCHAR2(60) NOT NULL,
588 pp_value
BLOB NOT NULL
590 CREATE UNIQUE INDEX &mw_prefix.page_props_u01
ON &mw_prefix.
page_props (pp_page
,pp_propname
);
593 CREATE TABLE &mw_prefix.
updatelog (
594 ul_key
VARCHAR2(255) NOT NULL,
597 ALTER TABLE &mw_prefix.updatelog
ADD CONSTRAINT &mw_prefix.updatelog_pk
PRIMARY KEY (ul_key
);
599 CREATE TABLE &mw_prefix.
change_tag (
600 ct_rc_id
NUMBER NULL,
601 ct_log_id
NUMBER NULL,
602 ct_rev_id
NUMBER NULL,
603 ct_tag
VARCHAR2(255) NOT NULL,
606 CREATE UNIQUE INDEX &mw_prefix.change_tag_u01
ON &mw_prefix.
change_tag (ct_rc_id
,ct_tag
);
607 CREATE UNIQUE INDEX &mw_prefix.change_tag_u02
ON &mw_prefix.
change_tag (ct_log_id
,ct_tag
);
608 CREATE UNIQUE INDEX &mw_prefix.change_tag_u03
ON &mw_prefix.
change_tag (ct_rev_id
,ct_tag
);
609 CREATE INDEX &mw_prefix.change_tag_i01
ON &mw_prefix.
change_tag (ct_tag
,ct_rc_id
,ct_rev_id
,ct_log_id
);
611 CREATE TABLE &mw_prefix.
tag_summary (
612 ts_rc_id
NUMBER NULL,
613 ts_log_id
NUMBER NULL,
614 ts_rev_id
NUMBER NULL,
615 ts_tags
BLOB NOT NULL
617 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u01
ON &mw_prefix.
tag_summary (ts_rc_id
);
618 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u02
ON &mw_prefix.
tag_summary (ts_log_id
);
619 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u03
ON &mw_prefix.
tag_summary (ts_rev_id
);
621 CREATE TABLE &mw_prefix.
valid_tag (
622 vt_tag
VARCHAR2(255) NOT NULL
624 ALTER TABLE &mw_prefix.valid_tag
ADD CONSTRAINT &mw_prefix.valid_tag_pk
PRIMARY KEY (vt_tag
);
626 -- This table is not used unless profiling is turned on
627 --CREATE TABLE &mw_prefix.profiling (
628 -- pf_count NUMBER DEFAULT 0 NOT NULL,
629 -- pf_time NUMERIC(18,10) DEFAULT 0 NOT NULL,
630 -- pf_name CLOB NOT NULL,
631 -- pf_server CLOB NULL
633 --CREATE UNIQUE INDEX &mw_prefix.profiling_u01 ON &mw_prefix.profiling (pf_name, pf_server);
635 CREATE INDEX &mw_prefix.si_title_idx
ON &mw_prefix.
searchindex(si_title
) INDEXTYPE
IS ctxsys.context
;
636 CREATE INDEX &mw_prefix.si_text_idx
ON &mw_prefix.
searchindex(si_text
) INDEXTYPE
IS ctxsys.context
;
638 CREATE TABLE &mw_prefix.
l10n_cache (
639 lc_lang
varchar2(32) NOT NULL,
640 lc_key
varchar2(255) NOT NULL,
641 lc_value
clob NOT NULL
643 CREATE INDEX &mw_prefix.l10n_cache_u01
ON &mw_prefix.
l10n_cache (lc_lang
, lc_key
);
645 CREATE TABLE &mw_prefix.
msg_resource (
646 mr_resource
VARCHAR2(255) NOT NULL,
647 mr_lang
varchar2(32) NOT NULL,
648 mr_blob
BLOB NOT NULL,
649 mr_timestamp
TIMESTAMP(6) WITH TIME ZONE NOT NULL
651 CREATE UNIQUE INDEX &mw_prefix.msg_resource_u01
ON &mw_prefix.
msg_resource (mr_resource
, mr_lang
);
653 CREATE TABLE &mw_prefix.
msg_resource_links (
654 mrl_resource
VARCHAR2(255) NOT NULL,
655 mrl_message
VARCHAR2(255) NOT NULL
657 CREATE UNIQUE INDEX &mw_prefix.msg_resource_links_u01
ON &mw_prefix.
msg_resource_links (mrl_message
, mrl_resource
);
659 CREATE TABLE &mw_prefix.
module_deps (
660 md_module
VARCHAR2(255) NOT NULL,
661 md_skin
VARCHAR2(32) NOT NULL,
662 md_deps
BLOB NOT NULL
664 CREATE UNIQUE INDEX &mw_prefix.module_deps_u01
ON &mw_prefix.
module_deps (md_module
, md_skin
);
666 CREATE TABLE &mw_prefix.
config (
667 cf_name
VARCHAR2(255) NOT NULL,
668 cf_value
blob NOT NULL
670 ALTER TABLE &mw_prefix.config
ADD CONSTRAINT &mw_prefix.config_pk
PRIMARY KEY (cf_name
);
671 -- leaving index out for now ...
673 -- do not prefix this table as it breaks parserTests
674 CREATE TABLE wiki_field_info_full (
675 table_name VARCHAR2(35) NOT NULL,
676 column_name VARCHAR2(35) NOT NULL,
677 data_default
VARCHAR2(4000),
678 data_length
NUMBER NOT NULL,
679 data_type
VARCHAR2(106),
680 not_null
CHAR(1) NOT NULL,
685 ALTER TABLE wiki_field_info_full
ADD CONSTRAINT wiki_field_info_full_pk
PRIMARY KEY (table_name, column_name);
688 CREATE PROCEDURE fill_wiki_info
IS
690 DELETE wiki_field_info_full
;
692 FOR x_rec
IN (SELECT t.
table_name table_name, t.
column_name,
693 t.data_default
, t.data_length
, t.data_type
,
694 DECODE (t.
nullable, 'Y', '1', 'N', '0') not_null
,
696 FROM user_cons_columns ucc
,
698 WHERE ucc.
table_name = t.
table_name
699 AND ucc.
column_name = t.
column_name
700 AND uc.
constraint_name = ucc.
constraint_name
701 AND uc.constraint_type
= 'P'
702 AND ROWNUM
< 2) prim
,
704 FROM user_ind_columns uic
,
706 WHERE uic.
table_name = t.
table_name
707 AND uic.
column_name = t.
column_name
708 AND ui.index_name
= uic.index_name
709 AND ui.uniqueness
= 'UNIQUE'
710 AND ROWNUM
< 2) uniq
,
712 FROM user_ind_columns uic
,
714 WHERE uic.
table_name = t.
table_name
715 AND uic.
column_name = t.
column_name
716 AND ui.index_name
= uic.index_name
717 AND ui.uniqueness
= 'NONUNIQUE'
718 AND ROWNUM
< 2) nonuniq
719 FROM user_tab_columns t
, user_tables ut
720 WHERE ut.
table_name = t.
table_name)
722 INSERT INTO wiki_field_info_full
723 (table_name, column_name,
724 data_default
, data_length
,
725 data_type
, not_null
, prim
,
728 VALUES (x_rec.
table_name, x_rec.
column_name,
729 x_rec.data_default
, x_rec.data_length
,
730 x_rec.data_type
, x_rec.not_null
, x_rec.prim
,
731 x_rec.uniq
, x_rec.nonuniq
739 CREATE OR REPLACE PROCEDURE duplicate_table(p_tabname
IN VARCHAR2,
740 p_oldprefix
IN VARCHAR2,
741 p_newprefix
IN VARCHAR2,
742 p_temporary
IN BOOLEAN) IS
743 e_table_not_exist
EXCEPTION;
744 PRAGMA
EXCEPTION_INIT(e_table_not_exist
, -00942);
745 l_temp_ei_sql
VARCHAR2(2000);
746 l_temporary
BOOLEAN := p_temporary
;
749 EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname ||
750 ' CASCADE CONSTRAINTS PURGE';
752 WHEN e_table_not_exist
THEN
755 IF (p_tabname
= 'SEARCHINDEX') THEN
756 l_temporary
:= FALSE;
758 IF (l_temporary
) THEN
759 EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix ||
761 ' ON COMMIT PRESERVE ROWS AS SELECT * FROM ' ||
762 p_oldprefix || p_tabname ||
' WHERE ROWNUM = 0';
764 EXECUTE IMMEDIATE 'CREATE TABLE ' || p_newprefix || p_tabname ||
765 ' AS SELECT * FROM ' || p_oldprefix || p_tabname ||
768 FOR rc
IN (SELECT column_name, data_default
769 FROM user_tab_columns
770 WHERE table_name = p_oldprefix || p_tabname
771 AND data_default
IS NOT NULL) LOOP
772 EXECUTE IMMEDIATE 'ALTER TABLE ' || p_newprefix || p_tabname ||
773 ' MODIFY ' || rc.
column_name ||
' DEFAULT ' ||
774 SUBSTR(rc.data_default
, 1, 2000);
776 FOR rc
IN (SELECT REPLACE(REPLACE(DBMS_LOB.
SUBSTR(DBMS_METADATA.
get_ddl('CONSTRAINT',
780 USER ||
'"."' || p_oldprefix
,
781 USER ||
'"."' || p_newprefix
),
782 '"' ||
constraint_name ||
'"',
783 '"' || p_newprefix ||
constraint_name ||
'"') DDLVC2
,
785 FROM user_constraints uc
786 WHERE table_name = p_oldprefix || p_tabname
787 AND constraint_type
= 'P') LOOP
788 l_temp_ei_sql
:= SUBSTR(rc.ddlvc2
, 1, INSTR(rc.ddlvc2
, 'PCTFREE') - 1);
789 l_temp_ei_sql
:= SUBSTR(l_temp_ei_sql
,
793 INSTR(l_temp_ei_sql
, 'PRIMARY KEY') + 1) + 1);
794 IF nvl(length(l_temp_ei_sql
), 0) > 0 THEN
795 EXECUTE IMMEDIATE l_temp_ei_sql
;
798 IF (NOT l_temporary
) THEN
799 FOR rc
IN (SELECT REPLACE(DBMS_LOB.
SUBSTR(DBMS_METADATA.
get_ddl('REF_CONSTRAINT',
803 USER ||
'"."' || p_oldprefix
,
804 USER ||
'"."' || p_newprefix
) DDLVC2
,
806 FROM user_constraints uc
807 WHERE table_name = p_oldprefix || p_tabname
808 AND constraint_type
= 'R') LOOP
809 IF nvl(length(l_temp_ei_sql
), 0) > 0 AND
810 INSTR(l_temp_ei_sql
, 'PRIMARY KEY') = 0 THEN
811 EXECUTE IMMEDIATE l_temp_ei_sql
;
815 FOR rc
IN (SELECT REPLACE(REPLACE(DBMS_LOB.
SUBSTR(DBMS_METADATA.
get_ddl('INDEX',
819 USER ||
'"."' || p_oldprefix
,
820 USER ||
'"."' || p_newprefix
),
821 '"' || index_name ||
'"',
822 '"' || p_newprefix || index_name ||
'"') DDLVC2
,
826 WHERE table_name = p_oldprefix || p_tabname
827 AND index_type
NOT IN ('LOB', 'DOMAIN')
830 FROM user_constraints
831 WHERE table_name = ui.
table_name
832 AND constraint_name = ui.index_name
)) LOOP
833 l_temp_ei_sql
:= SUBSTR(rc.ddlvc2
, 1, INSTR(rc.ddlvc2
, 'PCTFREE') - 1);
834 l_temp_ei_sql
:= SUBSTR(l_temp_ei_sql
,
839 '"' ||
USER ||
'"."' || p_newprefix ||
'"') + 1) + 1);
840 IF nvl(length(l_temp_ei_sql
), 0) > 0 THEN
841 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
= '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
:= rc.ddlvc2
;
863 IF nvl(length(l_temp_ei_sql
), 0) > 0 THEN
864 EXECUTE IMMEDIATE l_temp_ei_sql
;
867 FOR rc
IN (SELECT REPLACE(REPLACE(UPPER(DBMS_LOB.
SUBSTR(DBMS_METADATA.
get_ddl('TRIGGER',
871 USER ||
'"."' || p_oldprefix
,
872 USER ||
'"."' || p_newprefix
),
873 ' ON ' || p_oldprefix || p_tabname
,
874 ' ON ' || p_newprefix || p_tabname
) DDLVC2
,
877 WHERE table_name = p_oldprefix || p_tabname
) LOOP
878 l_temp_ei_sql
:= SUBSTR(rc.ddlvc2
, 1, INSTR(rc.ddlvc2
, 'ALTER ') - 1);
879 IF nvl(length(l_temp_ei_sql
), 0) > 0 THEN
880 EXECUTE IMMEDIATE l_temp_ei_sql
;
888 CREATE OR REPLACE FUNCTION BITOR (x
IN NUMBER, y
IN NUMBER) RETURN NUMBER AS
890 RETURN (x
+ y
- BITAND(x
, y
));
895 CREATE OR REPLACE FUNCTION BITNOT (x
IN NUMBER) RETURN NUMBER AS
897 RETURN (4294967295 - x
);
901 CREATE OR REPLACE TYPE GET_OUTPUT_TYPE
IS TABLE OF VARCHAR2(255);
904 CREATE OR REPLACE FUNCTION GET_OUTPUT_LINES
RETURN GET_OUTPUT_TYPE PIPELINED
AS
905 v_line
VARCHAR2(255);
906 v_status
INTEGER := 0;
910 DBMS_OUTPUT.
GET_LINE(v_line
, v_status
);
911 IF (v_status
= 0) THEN RETURN; END IF;
922 CREATE OR REPLACE FUNCTION GET_SEQUENCE_VALUE(seq
IN VARCHAR2) RETURN NUMBER AS
925 EXECUTE IMMEDIATE 'SELECT '||seq||
'.NEXTVAL INTO :outVar FROM DUAL' INTO v_value
;