pg分区表-按HASH
最后更新:2024-05-16 05:30:00
|
状态:未完成
|
相关数据库:
PostgreSQL
Table table = service.metadata().table("user_master", false); if(null != table){ service.ddl().drop(table); } MasterTable master = new MasterTable("user_master"); master.addColumn("ID", "INT"); master.addColumn("NAME", "VARCHAR(10)").setComment("姓名"); master.addColumn("DEPT_CODE", "int").setComment("部门ID"); //或者 master.setPartition(Partition.TYPE.HASH, "DEPT_CODE"); service.ddl().create(master); PartitionTable u1 = new PartitionTable("U1"); u1.setMaster(master); u1.setPartition(new Partition().setHash(3,0)); service.ddl().create(u1); PartitionTable u2 = new PartitionTable("U2"); u2.setMaster(master); u2.setPartition(new Partition().setHash(3,1)); service.ddl().create(u2); PartitionTable u3 = new PartitionTable("U3"); u3.setMaster(master); u3.setPartition(new Partition().setHash(3,2)); service.ddl().create(u3); DataRow user = new DataRow(); user.put("DEPT_CODE",5);//部门编号必须是子表 分区依据中出现的 并 操持大小写一致 user.put("NAME","ZH_FI"); //通过主表插入 service.insert("user_master", user); //从主表或相就的分区表中可以查到 service.querys("user_master"); service.querys("u3");