pg分区表-按范围(range)
最后更新:2024-05-15 05:30:01
|
状态:未完成
|
相关数据库:
PostgreSQL
//根据范围分区 Table table = service.metadata().table("log_master", false); if(null != table){ service.ddl().drop(table); } MasterTable master = new MasterTable("log_master"); master.addColumn("ID", "INT"); master.addColumn("NAME", "VARCHAR(10)").setComment("姓名"); Partition partition = new Partition(); partition.setType(Partition.TYPE.RANGE); partition.addColumn("ID"); master.setPartition(partition); //或者 master.setPartition(Partition.TYPE.RANGE, "ID"); service.ddl().create(master); PartitionTable log1 = new PartitionTable("LOG1"); log1.setMaster(master); log1.setPartition(new Partition(Partition.TYPE.RANGE).setFrom(0).setTo(99)); service.ddl().create(log1); PartitionTable log2 = new PartitionTable("LOG2"); log2.setMaster(master); //也可以不设置type共用主表的type log2.setPartition(new Partition().setFrom(100).setTo(199)); service.ddl().create(log2); DataRow log = new DataRow(); log.put("ID", 111); log.put("NAME","z"); service.insert("log_master", log); //从主表或相就的分区表中可以查到 service.querys("log_master"); service.querys("LOG2");