当前位置:网站首页>Oracle database and table
Oracle database and table
2022-06-22 16:33:00 【thoughtCodes】
oracle Sub database and sub table
Survive by day and develop by night.
talk is cheap, show me the code,make a better result.
Catalog
summary
oracle How to divide databases and tables ?
demand :
1. introduce POM
2. yaml To configure
3. DDL
4. Prepare the test object
5. test
Design thinking
Analysis of implementation ideas
1. introduce POM
<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>${sharding.jdbc.version}</version>
</dependency>
2.yaml To configure
sharding:
jdbc:
datasource:
names: ds0
# data source ds0
ds0:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: oracle.jdbc.driver.OracleDriver
url: jdbc:oracle:thin:@localhost:1521:xe
username: ******
password: ******
config:
sharding:
props:
sql.show: true
tables:
t_user: #t_user surface
key-generator-column-name: id # Primary key
actual-data-nodes: ds0.t_userKaTeX parse error: Expected 'EOF', got '#' at position 11: {0..1} #̲ Data nodes , Uniform distribution …{task_id % 2} # Assign by modulo
3. Preparation form DDL
2.3 Preparation form DDL
create table T_ADDRESS
(
ID NUMBER(20) not null
constraint T_ADDRESS_PK
primary key,
NAME VARCHAR2(64),
ADDR VARCHAR2(32)
)
/
comment on column T_ADDRESS.ID is ‘ Primary key ’
/
comment on column T_ADDRESS.NAME is ‘ name ’
/
comment on column T_ADDRESS.ADDR is ‘ Address ’
/
create table T_USER0
(
ID NUMBER(20) not null
constraint TABLE1_PK
primary key,
NAME VARCHAR2(64),
TASK_ID NUMBER(12),
CALL_MONTH VARCHAR2(20)
)
/
comment on column T_USER0.ID is ‘ Primary key ’
/
comment on column T_USER0.NAME is ‘ name ’
/
comment on column T_USER0.TASK_ID is ‘ Mission id’
/
comment on column T_USER0.CALL_MONTH is ‘ Call month ’
/
create table T_USER1
(
ID NUMBER(20) not null
constraint T_USER1_PK
primary key,
NAME VARCHAR2(64),
TASK_ID NUMBER(12),
CALL_MONTH VARCHAR2(20)
)
/
comment on column T_USER1.ID is ‘ Primary key ’
/
comment on column T_USER1.NAME is ‘ name ’
/
comment on column T_USER1.TASK_ID is ‘ Mission id’
/
comment on column T_USER1.CALL_MONTH is ‘ Call month ’
/
4. Prepare the test object
Test objects regardless of table :
@Test
public void save() {
for (int i = 0; i < 10; i++) {
Address address = new Address();
Long id = i + 1L;
address.setId(id);
address.setName(“name_” + i);
address.setAddr(“addr_” + i);
addressMapper.save(address);
}
}
5. Sub table test object
@Test
public void testSave() {
for (int i = 0; i < 10; i++) {
User user = new User();
Long id =i+1L;
user.setId(id);
user.setName(“test” + i);
user.setCallMonth(“201907”);
user.setTaskId(2L);
userMapper.save(user);
}
}
Expand to achieve
Reference here :github: Simply implement the above process :
Entry level implementation :
: Partial source code implementation .
: The source code to achieve
Performance parameter test :
nothing
References and recommended readings
Welcome to , Dear brother , If it helps you , A little praise and a little attention !~
边栏推荐
猜你喜欢
随机推荐
天翼云乘风新基建,构建数字化转型“4+2”能力体系
论催收系统的任务调度设计
SAP ABAP report programming-08
What is the difference between "img" and "ALT" in the interview question
Smart forms-014 in SAP ABAP
执行逻辑大同小异的实现类使用模板模式
Test for API
Interface idempotent design
数睿数据受邀参与南通企业数字化转型研讨会
10款超牛Vim插件,爱不释手了
Unity游戏优化(第2版)学习记录8
What is SAP ABAP? Type, ABAP full form and meaning
Unity game optimization (version 2) learning record 8
畅享高性能计算!天翼云HPC解决方案来了
Simple understanding of asynchronous IO
音视频基础知识|ANS 噪声抑制原理解析
短视频源码开发,优质的短视频源码需要做好哪几点?
SAP教程中的ALV报告 - ABAP列表查看器-012
毕业季·本科毕业感想——机械er的自救之路
用递归法求Fibonacci数列第n项的值









