oracle.sql 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. CREATE TABLE acl_classes (id NUMBER(10) NOT NULL, class_type VARCHAR2(200) NOT NULL, PRIMARY KEY(id))
  2. DECLARE
  3. constraints_Count NUMBER;
  4. BEGIN
  5. SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'ACL_CLASSES' AND CONSTRAINT_TYPE = 'P';
  6. IF constraints_Count = 0 OR constraints_Count = '' THEN
  7. EXECUTE IMMEDIATE 'ALTER TABLE ACL_CLASSES ADD CONSTRAINT ACL_CLASSES_AI_PK PRIMARY KEY (ID)';
  8. END IF;
  9. END;
  10. CREATE SEQUENCE ACL_CLASSES_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1
  11. CREATE TRIGGER ACL_CLASSES_AI_PK
  12. BEFORE INSERT
  13. ON ACL_CLASSES
  14. FOR EACH ROW
  15. DECLARE
  16. last_Sequence NUMBER;
  17. last_InsertID NUMBER;
  18. BEGIN
  19. SELECT ACL_CLASSES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
  20. IF (:NEW.ID IS NULL OR :NEW.ID = 0) THEN
  21. SELECT ACL_CLASSES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
  22. ELSE
  23. SELECT NVL(Last_Number, 0) INTO last_Sequence
  24. FROM User_Sequences
  25. WHERE Sequence_Name = 'ACL_CLASSES_SEQ';
  26. SELECT :NEW.ID INTO last_InsertID FROM DUAL;
  27. WHILE (last_InsertID > last_Sequence) LOOP
  28. SELECT ACL_CLASSES_SEQ.NEXTVAL INTO last_Sequence FROM DUAL;
  29. END LOOP;
  30. END IF;
  31. END;
  32. CREATE UNIQUE INDEX UNIQ_69DD750638A36066 ON acl_classes (class_type)
  33. CREATE TABLE acl_security_identities (id NUMBER(10) NOT NULL, identifier VARCHAR2(200) NOT NULL, username NUMBER(1) NOT NULL, PRIMARY KEY(id))
  34. DECLARE
  35. constraints_Count NUMBER;
  36. BEGIN
  37. SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'ACL_SECURITY_IDENTITIES' AND CONSTRAINT_TYPE = 'P';
  38. IF constraints_Count = 0 OR constraints_Count = '' THEN
  39. EXECUTE IMMEDIATE 'ALTER TABLE ACL_SECURITY_IDENTITIES ADD CONSTRAINT ACL_SECURITY_IDENTITIES_AI_PK PRIMARY KEY (ID)';
  40. END IF;
  41. END;
  42. CREATE SEQUENCE ACL_SECURITY_IDENTITIES_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1
  43. CREATE TRIGGER ACL_SECURITY_IDENTITIES_AI_PK
  44. BEFORE INSERT
  45. ON ACL_SECURITY_IDENTITIES
  46. FOR EACH ROW
  47. DECLARE
  48. last_Sequence NUMBER;
  49. last_InsertID NUMBER;
  50. BEGIN
  51. SELECT ACL_SECURITY_IDENTITIES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
  52. IF (:NEW.ID IS NULL OR :NEW.ID = 0) THEN
  53. SELECT ACL_SECURITY_IDENTITIES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
  54. ELSE
  55. SELECT NVL(Last_Number, 0) INTO last_Sequence
  56. FROM User_Sequences
  57. WHERE Sequence_Name = 'ACL_SECURITY_IDENTITIES_SEQ';
  58. SELECT :NEW.ID INTO last_InsertID FROM DUAL;
  59. WHILE (last_InsertID > last_Sequence) LOOP
  60. SELECT ACL_SECURITY_IDENTITIES_SEQ.NEXTVAL INTO last_Sequence FROM DUAL;
  61. END LOOP;
  62. END IF;
  63. END;
  64. CREATE UNIQUE INDEX UNIQ_8835EE78772E836AF85E0677 ON acl_security_identities (identifier, username)
  65. CREATE TABLE acl_object_identities (id NUMBER(10) NOT NULL, parent_object_identity_id NUMBER(10) DEFAULT NULL NULL, class_id NUMBER(10) NOT NULL, object_identifier VARCHAR2(100) NOT NULL, entries_inheriting NUMBER(1) NOT NULL, PRIMARY KEY(id))
  66. DECLARE
  67. constraints_Count NUMBER;
  68. BEGIN
  69. SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'ACL_OBJECT_IDENTITIES' AND CONSTRAINT_TYPE = 'P';
  70. IF constraints_Count = 0 OR constraints_Count = '' THEN
  71. EXECUTE IMMEDIATE 'ALTER TABLE ACL_OBJECT_IDENTITIES ADD CONSTRAINT ACL_OBJECT_IDENTITIES_AI_PK PRIMARY KEY (ID)';
  72. END IF;
  73. END;
  74. CREATE SEQUENCE ACL_OBJECT_IDENTITIES_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1
  75. CREATE TRIGGER ACL_OBJECT_IDENTITIES_AI_PK
  76. BEFORE INSERT
  77. ON ACL_OBJECT_IDENTITIES
  78. FOR EACH ROW
  79. DECLARE
  80. last_Sequence NUMBER;
  81. last_InsertID NUMBER;
  82. BEGIN
  83. SELECT ACL_OBJECT_IDENTITIES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
  84. IF (:NEW.ID IS NULL OR :NEW.ID = 0) THEN
  85. SELECT ACL_OBJECT_IDENTITIES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
  86. ELSE
  87. SELECT NVL(Last_Number, 0) INTO last_Sequence
  88. FROM User_Sequences
  89. WHERE Sequence_Name = 'ACL_OBJECT_IDENTITIES_SEQ';
  90. SELECT :NEW.ID INTO last_InsertID FROM DUAL;
  91. WHILE (last_InsertID > last_Sequence) LOOP
  92. SELECT ACL_OBJECT_IDENTITIES_SEQ.NEXTVAL INTO last_Sequence FROM DUAL;
  93. END LOOP;
  94. END IF;
  95. END;
  96. CREATE UNIQUE INDEX UNIQ_9407E5494B12AD6EA000B10 ON acl_object_identities (object_identifier, class_id)
  97. CREATE INDEX IDX_9407E54977FA751A ON acl_object_identities (parent_object_identity_id)
  98. CREATE TABLE acl_object_identity_ancestors (object_identity_id NUMBER(10) NOT NULL, ancestor_id NUMBER(10) NOT NULL, PRIMARY KEY(object_identity_id, ancestor_id))
  99. CREATE INDEX IDX_825DE2993D9AB4A6 ON acl_object_identity_ancestors (object_identity_id)
  100. CREATE INDEX IDX_825DE299C671CEA1 ON acl_object_identity_ancestors (ancestor_id)
  101. CREATE TABLE acl_entries (id NUMBER(10) NOT NULL, class_id NUMBER(10) NOT NULL, object_identity_id NUMBER(10) DEFAULT NULL NULL, security_identity_id NUMBER(10) NOT NULL, field_name VARCHAR2(50) DEFAULT NULL NULL, ace_order NUMBER(5) NOT NULL, mask NUMBER(10) NOT NULL, granting NUMBER(1) NOT NULL, granting_strategy VARCHAR2(30) NOT NULL, audit_success NUMBER(1) NOT NULL, audit_failure NUMBER(1) NOT NULL, PRIMARY KEY(id))
  102. DECLARE
  103. constraints_Count NUMBER;
  104. BEGIN
  105. SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'ACL_ENTRIES' AND CONSTRAINT_TYPE = 'P';
  106. IF constraints_Count = 0 OR constraints_Count = '' THEN
  107. EXECUTE IMMEDIATE 'ALTER TABLE ACL_ENTRIES ADD CONSTRAINT ACL_ENTRIES_AI_PK PRIMARY KEY (ID)';
  108. END IF;
  109. END;
  110. CREATE SEQUENCE ACL_ENTRIES_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1
  111. CREATE TRIGGER ACL_ENTRIES_AI_PK
  112. BEFORE INSERT
  113. ON ACL_ENTRIES
  114. FOR EACH ROW
  115. DECLARE
  116. last_Sequence NUMBER;
  117. last_InsertID NUMBER;
  118. BEGIN
  119. SELECT ACL_ENTRIES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
  120. IF (:NEW.ID IS NULL OR :NEW.ID = 0) THEN
  121. SELECT ACL_ENTRIES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
  122. ELSE
  123. SELECT NVL(Last_Number, 0) INTO last_Sequence
  124. FROM User_Sequences
  125. WHERE Sequence_Name = 'ACL_ENTRIES_SEQ';
  126. SELECT :NEW.ID INTO last_InsertID FROM DUAL;
  127. WHILE (last_InsertID > last_Sequence) LOOP
  128. SELECT ACL_ENTRIES_SEQ.NEXTVAL INTO last_Sequence FROM DUAL;
  129. END LOOP;
  130. END IF;
  131. END;
  132. CREATE UNIQUE INDEX UNIQ_46C8B806EA000B103D9AB4A64DEF17BCE4289BF4 ON acl_entries (class_id, object_identity_id, field_name, ace_order)
  133. CREATE INDEX IDX_46C8B806EA000B103D9AB4A6DF9183C9 ON acl_entries (class_id, object_identity_id, security_identity_id)
  134. CREATE INDEX IDX_46C8B806EA000B10 ON acl_entries (class_id)
  135. CREATE INDEX IDX_46C8B8063D9AB4A6 ON acl_entries (object_identity_id)
  136. CREATE INDEX IDX_46C8B806DF9183C9 ON acl_entries (security_identity_id)
  137. ALTER TABLE acl_object_identities ADD CONSTRAINT FK_9407E54977FA751A FOREIGN KEY (parent_object_identity_id) REFERENCES acl_object_identities (id)
  138. ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE2993D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON DELETE CASCADE
  139. ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE299C671CEA1 FOREIGN KEY (ancestor_id) REFERENCES acl_object_identities (id) ON DELETE CASCADE
  140. ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806EA000B10 FOREIGN KEY (class_id) REFERENCES acl_classes (id) ON DELETE CASCADE
  141. ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B8063D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON DELETE CASCADE
  142. ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806DF9183C9 FOREIGN KEY (security_identity_id) REFERENCES acl_security_identities (id) ON DELETE CASCADE