如果未添加多个(但不是全部)表到PostgreSQL发布中

时间:2019-06-26 09:24:12

标签: sql django postgresql

我正在尝试在PostgreSQL 10数据库上设置发布以进行逻辑复制。

该数据库用于Django网站,当前所有表都处于一种模式-0中。我计划通过Django迁移来保持数据库结构的更新,因此我需要从PostgreSQL发布中排除一些表,即所有以class Board { private var content: [[Animal?]] = [] private static func setupForNewGame(width: Int,height: Int)->[[Animal?]] { var matrix:[[Animal?]] = Array(repeating: Array(repeating: nil, count: width), count: height) let cellCount = Double(width * height) let fishCount = Int(cellCount * 35.0 / 100.0) let orcaCount = Int(cellCount * 5.0 / 100.0) var arr:[Animal?] = Array(1...fishCount).map { _ in Fish() } + Array(1...orcaCount).map { _ in Orca() } + Array(repeating: nil, count: Int(cellCount)-fishCount-orcaCount) arr = arr.shuffled() var counter = 0 for i in 0...width - 1{ for j in 0...height - 1{ matrix[i][j] = arr[counter] counter = counter + 1 } } return matrix } } 开头的表。

我可以收到需要使用查询复制的表的完整列表

public

使用查询将表添加到发布中

django

如何将我的SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname='public' and tablename not like 'django%'; 查询的输出传递给上述ALTER PUBLICATION my_publication ADD TABLE table0, table1; 查询?

如果跳过已经添加的表而不是中断整个SELECT查询的执行,那也很好。

目前,我认为我将不得不使用PL/pgSQL - SQL Procedural Language。但是也许有一种更好/更简单的方法来仅通过查询来编辑发布?

0 个答案:

没有答案