---
name: "SET_ADD_TABLE"
section: "7"
platform: "linux"
package: "slony1-doc"
version: "1.2.15-1"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/SET_ADD_TABLE"
---

# SET\_ADD\_TABLE(7)

Add a table to a Slony-I replication set

## NAME

SET ADD TABLE - Add a table to a Slony-I replication set

## SYNOPSIS

**SET ADD TABLE (options);**

## DESCRIPTION

Add an existing usep table to a replication set. The set cannot currently be subscribed by any other node - that functionality is supported by the **MERGE** [**SET**(7)](/SET/7.md) command.

- FCSET ID = ival F\[0\]

  ID of the set to which the table is to be added.

- FCORIGIN = ival F\[0\]

  Origin node for the set. A future version of slonik might figure out this information by itself.

- FCID = ival F\[0\]

  Unique ID of the table. These ID's are not only used to uniquely identify the individual table within the replication system. The numeric value of this ID also determines the order in which the tables are locked in a **LOCK SET**(7) command for example. So these numbers should represent any applicable table hierarchy to make sure the slonik command scripts do not deadlock at any critical moment.

  This ID must be unique across all sets; you cannot have two tables in the same cluster with the same ID.

- FCFULLY QUALIFIED NAME = 'string' F\[0\]

  The full table name as described in **TABLE ADD KEY**(7).

- FCKEY = { 'string' \| SERIAL } F\[0\]

  *(Optional)* The index name that covers the unique and not null set of columns to be used as the row identifier for replication purposes. Or the keyword SERIAL to use the special column added with a previous **TABLE ADD KEY**(7) command. Default is to use the table's primary key. The index name is *not* fully qualified; you must omit the namespace.

- FCCOMMENT = 'string' F\[0\]

  A descriptive text added to the table entry.

This uses “schemadocsetaddtable( integer, integer, text, name, text )” \[not available as a man page\].

## EXAMPLE

```
FCSET ADD TABLE (
    SET ID = 1,
    ORIGIN = 1,
    ID = 20,
    FULLY QUALIFIED NAME = 'public.tracker_ticket',
    COMMENT = 'Support ticket'
);
    F[0]
```

## ERROR MESSAGES

Here are some of the error messages you may encounter if adding tables incorrectly:

- FCSlony-I: setAddTable\_int: table public.my\_table PK column id nullable F\[0\]

  Primary keys (or candidates thereof) are required to have all column defined as **NOT** **NULL**. If you have a PK candidate that has columns that are not thus restricted, Slony-I will reject the table with this message.

- FCSlony-I: setAddTable\_int: table id 14 has already been assigned! F\[0\]

  The table id, stored in **sl\_table.tab\_id**, is required to be unique across all tables/nodes/sets. Apparently you have tried to reused a table ID.

- FCSlony-I: setAddTable\_int(): table public.my\_table has no index mt\_idx\_14F\[0\]

  This will normally occur with candidate primary keys; apparently the index specified is not available on this node.

- FCSlony-I: setAddTable\_int(): table public.my\_table not found F\[0\]

  Worse than an index missing, the whole table is missing. Apparently whatever process you were using to get the schema into place everywhere didn't work properly.

- FCSlony-I: setAddTable\_int(): public.my\_view is not a regular table F\[0\]

  You can only replicate (at least, using **SET ADD TABLE**) objects that are ordinary tables. That doesn't include views or indexes. (Indexes can come along for the ride, but you don't ask to replicate an index...)

- FCSlony-I: setAddTable\_int(): set 4 not found F\[0\]

  You need to define a replication set before assigning tables to it.

- FCSlony-I: setAddTable(): set 4 has remote origin F\[0\]

  This will occur if set 4 is configured with, as origin, node 1, and then you submit a **SET ADD** **TABLE** request involving that set to some other node than node 1. This would be expected to occur if there was some confusion in the **admin conninfo** configuration in the slonik script preamble...

- FCSlony-I: cannot add table to currently subscribed set 1 F\[0\]

  Slony-I does not support adding tables to sets that are already participating in subscriptions. Probably you need to define a new set to associate additional tables to.

## LOCKING BEHAVIOUR

On the origin node, this operation requires a brief exclusive lock on the table in order to alter it to add the replication trigger. On subscriber nodes, corresponding locking takes place at the time of the **SUBSCRIBE\_SET** event.

## VERSION INFORMATION

This command was introduced in Slony-I 1.0
