-
Notifications
You must be signed in to change notification settings - Fork 4
/
nacos_oracle_11.sql
246 lines (245 loc) · 8.65 KB
/
nacos_oracle_11.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
CREATE TABLE "CONFIG_INFO" (
"ID" NUMBER ( 20, 0 ) not NULL ,
"DATA_ID" NVARCHAR2 ( 255 ) NOT NULL,
"GROUP_ID" NVARCHAR2 ( 255 ) DEFAULT NULL,
"CONTENT" CLOB NOT NULL,
"MD5" NVARCHAR2 ( 32 ),
"GMT_CREATE" DATE DEFAULT SYSDATE NOT NULL,
"GMT_MODIFIED" DATE DEFAULT SYSDATE NOT NULL,
"SRC_USER" CLOB,
"SRC_IP" NVARCHAR2 ( 50 ) DEFAULT NULL,
"APP_NAME" NVARCHAR2 ( 128 ) DEFAULT NULL,
"TENANT_ID" NVARCHAR2 ( 128 ) DEFAULT '',
"C_DESC" NVARCHAR2 ( 256 ) DEFAULT NULL,
"C_USE" NVARCHAR2 ( 64 ) DEFAULT NULL,
"EFFECT" NVARCHAR2 ( 64 ) DEFAULT NULL,
"TYPE" NVARCHAR2 ( 64 ) DEFAULT NULL,
"C_SCHEMA" CLOB,
CONSTRAINT "CI_PK_ID" PRIMARY KEY ( "ID" ),
CONSTRAINT "UK_CONFIGINFO_DATAGROUPTENANT" UNIQUE ( "DATA_ID", "GROUP_ID", "TENANT_ID" )
);
CREATE TABLE "CONFIG_INFO_AGGR" (
"ID" NUMBER ( 20, 0 ) not NULL,
"DATA_ID" NVARCHAR2 ( 255 ) NOT NULL,
"GROUP_ID" NVARCHAR2 ( 255 ) NOT NULL,
"DATUM_ID" NVARCHAR2 ( 255 ) NOT NULL,
"CONTENT" CLOB NOT NULL,
"GMT_MODIFIED" DATE DEFAULT SYSDATE NOT NULL,
"APP_NAME" NVARCHAR2 ( 128 ) DEFAULT NULL,
"TENANT_ID" NVARCHAR2 ( 128 ) DEFAULT '',
CONSTRAINT "CIA_PK_ID" PRIMARY KEY ( "ID" ),
CONSTRAINT "UK_CIA_DATAGROUPTENANTDATUM" UNIQUE ( "DATA_ID", "GROUP_ID", "TENANT_ID", "DATUM_ID" )
);
CREATE TABLE "CONFIG_INFO_BETA" (
"ID" NUMBER ( 20, 0 ) not NULL,
"DATA_ID" NVARCHAR2 ( 255 ) NOT NULL,
"GROUP_ID" NVARCHAR2 ( 128 ) NOT NULL,
"APP_NAME" NVARCHAR2 ( 128 ) DEFAULT NULL,
"CONTENT" CLOB NOT NULL,
"BETA_IPS" NVARCHAR2 ( 1024 ) DEFAULT NULL,
"MD5" NVARCHAR2 ( 32 ) DEFAULT NULL,
"GMT_CREATE" DATE DEFAULT SYSDATE NOT NULL,
"GMT_MODIFIED" DATE DEFAULT SYSDATE NOT NULL,
"SRC_USER" CLOB,
"SRC_IP" NVARCHAR2 ( 50 ),
"TENANT_ID" NVARCHAR2 ( 128 ) DEFAULT '',
CONSTRAINT "CIB_PK_ID" PRIMARY KEY ( "ID" ),
CONSTRAINT "UK_CIB_DATAGROUPTENANT" UNIQUE ( "DATA_ID", "GROUP_ID", "TENANT_ID" )
);
CREATE TABLE "CONFIG_INFO_TAG" (
"ID" NUMBER ( 20, 0 ) not NULL ,
"DATA_ID" NVARCHAR2 ( 255 ) NOT NULL,
"GROUP_ID" NVARCHAR2 ( 128 ) NOT NULL,
"TENANT_ID" NVARCHAR2 ( 128 ) DEFAULT '',
"TAG_ID" NVARCHAR2 ( 128 ) NOT NULL,
"APP_NAME" NVARCHAR2 ( 128 ) DEFAULT NULL,
"CONTENT" CLOB NOT NULL,
"MD5" NVARCHAR2 ( 32 ) DEFAULT NULL,
"GMT_CREATE" DATE DEFAULT SYSDATE NOT NULL,
"GMT_MODIFIED" DATE DEFAULT SYSDATE NOT NULL,
"SRC_USER" CLOB,
"SRC_IP" NVARCHAR2 ( 50 ),
CONSTRAINT "CIT_PK_ID" PRIMARY KEY ( "ID" ),
CONSTRAINT "UK_CIT_DATAGROUPTENANTTAG" UNIQUE ( "DATA_ID", "GROUP_ID", "TENANT_ID", "TAG_ID" )
);
CREATE TABLE "CONFIG_TAGS_RELATION" (
"ID" NUMBER ( 20, 0 ) not NULL,
"TAG_NAME" NVARCHAR2 ( 128 ) NOT NULL,
"TAG_TYPE" NVARCHAR2 ( 64 ) DEFAULT NULL,
"DATA_ID" NVARCHAR2 ( 255 ) NOT NULL,
"GROUP_ID" NVARCHAR2 ( 128 ) NOT NULL,
"TENANT_ID" NVARCHAR2 ( 128 ) DEFAULT '',
"NID" NUMBER ( 20, 0 ) NOT NULL,
CONSTRAINT "CTR_PK_ID" PRIMARY KEY ( "NID" ),
CONSTRAINT "UK_CTR_CONFIGIDTAG" UNIQUE ( "ID", "TAG_NAME", "TAG_TYPE" )
);
CREATE INDEX "IDX_CTR_TENANT_ID" ON CONFIG_TAGS_RELATION ( "TENANT_ID" );
CREATE TABLE "GROUP_CAPACITY" (
"ID" NUMBER ( 20, 0 ) not NULL ,
"GROUP_ID" NVARCHAR2 ( 128 ) DEFAULT '' NOT NULL,
"QUOTA" NUMBER ( 10, 0 ) DEFAULT 0 NOT NULL,
"USAGE" NUMBER ( 10, 0 ) DEFAULT 0 NOT NULL,
"MAX_SIZE" NUMBER ( 10, 0 ) DEFAULT 0 NOT NULL,
"MAX_AGGR_COUNT" NUMBER ( 10, 0 ) DEFAULT 0 NOT NULL,
"MAX_AGGR_SIZE" NUMBER ( 10, 0 ) DEFAULT 0 NOT NULL,
"MAX_HISTORY_COUNT" NUMBER ( 10, 0 ) DEFAULT 0 NOT NULL,
"GMT_CREATE" DATE DEFAULT SYSDATE NOT NULL,
"GMT_MODIFIED" DATE DEFAULT SYSDATE NOT NULL,
CONSTRAINT "GC_PK_ID" PRIMARY KEY ( "ID" ),
CONSTRAINT "UK_GC_GROUP_ID" UNIQUE ( "GROUP_ID" )
);
CREATE TABLE "HIS_CONFIG_INFO" (
"ID" NUMBER ( 20, 0 ) NOT NULL,
"NID" NUMBER ( 20, 0 ) not NULL,
"DATA_ID" NVARCHAR2 ( 255 ) NOT NULL,
"GROUP_ID" NVARCHAR2 ( 128 ) NOT NULL,
"APP_NAME" NVARCHAR2 ( 128 ) DEFAULT NULL,
"CONTENT" CLOB NOT NULL,
"MD5" NVARCHAR2 ( 32 ) DEFAULT NULL,
"GMT_CREATE" DATE DEFAULT SYSDATE NOT NULL,
"GMT_MODIFIED" DATE DEFAULT SYSDATE NOT NULL,
"SRC_USER" CLOB,
"SRC_IP" NVARCHAR2 ( 50 ) DEFAULT NULL,
"OP_TYPE" NCHAR ( 10 ) DEFAULT NULL,
"TENANT_ID" NVARCHAR2 ( 128 ) DEFAULT '',
CONSTRAINT "HCI_PK_ID" PRIMARY KEY ( "NID" )
);
CREATE INDEX "IDX_HCI_GMT_CREATE" ON HIS_CONFIG_INFO ( "GMT_CREATE" );
CREATE INDEX "IDX_HCI_GMT_MODIFIED" ON HIS_CONFIG_INFO ( "GMT_MODIFIED" );
CREATE INDEX "IDX_HCI_DID" ON HIS_CONFIG_INFO ( "DATA_ID" );
CREATE TABLE "TENANT_CAPACITY" (
"ID" NUMBER ( 20, 0 ) not NULL,
"TENANT_ID" NVARCHAR2 ( 128 ) DEFAULT '' NOT NULL,
"QUOTA" NUMBER ( 10, 0 ) DEFAULT 0 NOT NULL,
"USAGE" NUMBER ( 10, 0 ) DEFAULT 0 NOT NULL,
"MAX_SIZE" NUMBER ( 10, 0 ) DEFAULT 0 NOT NULL,
"MAX_AGGR_COUNT" NUMBER ( 10, 0 ) DEFAULT 0 NOT NULL,
"MAX_AGGR_SIZE" NUMBER ( 10, 0 ) DEFAULT 0 NOT NULL,
"MAX_HISTORY_COUNT" NUMBER ( 10, 0 ) DEFAULT 0 NOT NULL,
"GMT_CREATE" DATE DEFAULT SYSDATE NOT NULL,
"GMT_MODIFIED" DATE DEFAULT SYSDATE NOT NULL,
CONSTRAINT "TC_PK_ID" PRIMARY KEY ( "ID" ),
CONSTRAINT "UK_TC_TENANT_ID" UNIQUE ( "TENANT_ID" )
);
CREATE TABLE "TENANT_INFO" (
"ID" NUMBER ( 20, 0 ) not NULL,
"KP" NVARCHAR2 ( 128 ) NOT NULL,
"TENANT_ID" NVARCHAR2 ( 128 ) DEFAULT '',
"TENANT_NAME" NVARCHAR2 ( 128 ) DEFAULT '',
"TENANT_DESC" NVARCHAR2 ( 256 ) DEFAULT NULL,
"CREATE_SOURCE" NVARCHAR2 ( 32 ) DEFAULT NULL,
"GMT_CREATE" NUMBER ( 20, 0 ) NOT NULL,
"GMT_MODIFIED" NUMBER ( 20, 0 ) NOT NULL,
CONSTRAINT "TI_PK_ID" PRIMARY KEY ( "ID" ),
CONSTRAINT "UK_TENANT_INFO_KPTENANTID" UNIQUE ( "KP", "TENANT_ID" )
);
CREATE INDEX IDX_TI_TENANT_ID ON TENANT_INFO ( "TENANT_ID" );
CREATE TABLE "USERS" (
"USERNAME" NVARCHAR2 ( 50 ) NOT NULL,
"PASSWORD" NVARCHAR2 ( 500 ) NOT NULL,
"ENABLED" NUMBER ( 1, 0 ) DEFAULT 1 NOT NULL,
CONSTRAINT "USERS_PK_NAME" PRIMARY KEY ( "USERNAME" )
);
CREATE TABLE "ROLES" (
"USERNAME" NVARCHAR2 ( 50 ) NOT NULL,
"ROLE" NVARCHAR2 ( 50 ) NOT NULL,
CONSTRAINT "UK_USERNAME_ROLE" UNIQUE ( "USERNAME", "ROLE" )
);
CREATE TABLE "PERMISSIONS" (
"ROLE" NVARCHAR2 ( 50 ) NOT NULL,
"RESOURCE" NVARCHAR2 ( 512 ) NOT NULL,
"ACTION" NVARCHAR2 ( 8 ) NOT NULL,
CONSTRAINT UK_ROLE_PERMISSION UNIQUE ( "ROLE", "RESOURCE", "ACTION" )
);
INSERT INTO "USERS" ( "USERNAME", "PASSWORD", "ENABLED" ) VALUES( 'nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', 1 );
INSERT INTO "ROLES" ( "USERNAME", "ROLE" ) VALUES ( 'nacos', 'ROLE_ADMIN' );
create sequence seq_config_info;
create or replace trigger tg_config_info
--before:执行DML等操作之前触发
before insert on config_info
--行级触发器
for each row
begin
select seq_config_info.nextval into :new.id from dual;
end;
/
create sequence seq_config_tags_relation;
create or replace trigger tg_config_tags_relation
--before:执行DML等操作之前触发
before insert on config_tags_relation
--行级触发器
for each row
begin
select seq_config_tags_relation.nextval into :new.nid from dual;
end;
/
create sequence seq_config_info_aggr;
create or replace trigger tg_config_info_aggr
--before:
before insert on config_info_aggr
--行级触发器
for each row
begin
select seq_config_info_aggr.nextval into :new.id from dual;
end;
/
create sequence seq_config_info_beta;
create or replace trigger tg_config_info_beta
--before:
before insert on config_info_beta
--行级触发器
for each row
begin
select seq_config_info_beta.nextval into :new.id from dual;
end;
/
create sequence seq_config_info_tag;
create or replace trigger tg_config_info_tag
--before:
before insert on config_info_tag
--行级触发器
for each row
begin
select seq_config_info_tag.nextval into :new.id from dual;
end;
/
create sequence seq_group_capacity;
create or replace trigger tg_group_capacity
--before:
before insert on group_capacity
--行级触发器
for each row
begin
select seq_group_capacity.nextval into :new.id from dual;
end;
/
create sequence seq_his_config_info;
create or replace trigger tg_his_config_info
--before:
before insert on his_config_info
--行级触发器
for each row
begin
select seq_his_config_info.nextval into :new.nid from dual;
end;
/
create sequence seq_tenant_capacity;
create or replace trigger tg_tenant_capacity
--before:
before insert on tenant_capacity
--行级触发器
for each row
begin
select seq_tenant_capacity.nextval into :new.id from dual;
end;
/
create sequence seq_tenant_info;
create or replace trigger tg_tenant_info
--before:
before insert on tenant_info
--行级触发器
for each row
begin
select seq_tenant_info.nextval into :new.id from dual;
end;
/