TABLE ADD KEY

Name

TABLE ADD KEY --  Add primary key for use by Slony-I for a table with no suitable key

Synopsis

TABLE ADD KEY (options);

Description

In the Slony-I replication system, every replicated table is required to have at least one UNIQUE constraint whose columns are declared NOT NULL. Any primary key satisfies this requirement.

As a last resort, this command can be used to add such an attribute to a table that does not have a primary key. Since this modification can have unwanted side effects, it is strongly recommended that users add a unique and not null attribute by other means.

NODE ID = ival

Node ID of the set origin where the table will be added as a set member. (See SET ADD TABLE.)

FULLY QUALIFIED NAME = 'string'

The full name of the table consisting of the schema and table name as the SQL expression quote_ident(nspname) || '.' || quote_ident(relname) would return it.

Note: There is a limitation at present; you can create a PostgreSQL table with no columns, as with create table real_short (); . Slony-I will refuse to handle such a table. This isn't presently regarded as a serious limitation, as we can't see there being terribly much interest in replicating tables that contain no application data.

Caution

TABLE ADD KEY should not be used if you can possibly avoid it. It is emphatically not a Best Practice.

The absence of a proper primary key should be a big red flag that the database schema is broken. The right way to repair this is to introduce a proper primary key, not to have Slony-I "fake" one up.

It is not supported in log shipping, and will not be.

This uses schemadoctableaddkey( text ).

Example

     TABLE ADD KEY ( NODE ID = 1, 
     FULLY QUALIFIED NAME = 'public.history' );
    

Version Information

This command was introduced in Slony-I 1.0