提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.infra.service; |
H |
2 |
|
|
3 |
import cn.hutool.core.util.StrUtil; |
|
4 |
import com.baomidou.mybatisplus.generator.query.DefaultQuery; |
|
5 |
import com.baomidou.mybatisplus.generator.config.DataSourceConfig; |
|
6 |
import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder; |
|
7 |
import com.baomidou.mybatisplus.generator.config.po.TableInfo; |
|
8 |
|
|
9 |
import java.util.List; |
|
10 |
|
|
11 |
public class DefaultDatabaseQueryTest { |
|
12 |
|
|
13 |
public static void main(String[] args) { |
|
14 |
// DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder("jdbc:oracle:thin:@127.0.0.1:1521:xe", |
|
15 |
// "root", "123456").build(); |
|
16 |
DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder("jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro", |
|
17 |
"root", "123456").build(); |
|
18 |
// StrategyConfig strategyConfig = new StrategyConfig.Builder().build(); |
|
19 |
|
|
20 |
ConfigBuilder builder = new ConfigBuilder(null, dataSourceConfig, null, null, null, null); |
|
21 |
|
|
22 |
DefaultQuery query = new DefaultQuery(builder); |
|
23 |
|
|
24 |
long time = System.currentTimeMillis(); |
|
25 |
List<TableInfo> tableInfos = query.queryTables(); |
|
26 |
for (TableInfo tableInfo : tableInfos) { |
|
27 |
if (StrUtil.startWithAny(tableInfo.getName().toLowerCase(), "act_", "flw_", "qrtz_")) { |
|
28 |
continue; |
|
29 |
} |
|
30 |
System.out.println(String.format("CREATE SEQUENCE %s_seq MINVALUE 1;", tableInfo.getName())); |
|
31 |
// System.out.println(String.format("DELETE FROM %s WHERE deleted = '1';", tableInfo.getName())); |
|
32 |
} |
|
33 |
System.out.println(tableInfos.size()); |
|
34 |
System.out.println(System.currentTimeMillis() - time); |
|
35 |
} |
|
36 |
|
|
37 |
} |