Home / Repstance User Guide / DATABASE CONFIGURATION COMMANDS / Remove Repstance Objects from Database

Remove Repstance Objects from Database

The remove command removes the objects that prepare has created in a Source Database or in a Target Database. The tables that are replicated are not touched. A process that uses the database fails afterwards, so stop it first (see Stop any Capture or Apply Processes). The rules that all the database commands share and the messages are on DATABASE CONFIGURATION COMMANDS.

generatesql=1 does not stop the command: it removes the objects whatever its value.

What is removed

DatabaseWhat remove does
SQL Server SourceIt drops the database trigger, the SQL Server Agent jobs, the procedures, the functions, the tables and the schema repi, and it disables CDC for the whole database: CDC is switched off for all the tables of the database, also for the tables that other applications read with CDC. The tables hb_stat and ValidateTables stay while repi.apply_ckpt exists.
Oracle SourceIt drops the tables, the sequence, the functions, the packages and the types of the user REPI, and the user itself when it owns no other object. The supplemental logging, the Oracle directories and the grants stay.
MySQL SourceIt drops the tables repi.ld_capture and repi.ValidateTables, and the database repi when nothing else is in it.
PostgreSQL SourceIt drops the two event triggers, the three functions and the tables of the schema repi, and the schema when nothing else is in it. The slots and the publications of the Capture Processes stay until the Capture Process is removed (see Remove Process).
SQL Server TargetIt drops the checkpoint tables, the procedures and the schema repi. The tables hb_stat and ValidateTables stay while repi.dml_capture exists.
Oracle TargetIt drops the tables, the sequences and the procedures of the user REPI, and the user itself when it owns no other object.
PostgreSQL TargetIt drops the four tables and the four functions, and the schema repi when nothing is left in it.
MySQL TargetIt drops the four tables and the four procedures, and the database repi when no table is left.
Redshift and Snowflake TargetIt drops the schema repi with everything that is in it.
AWS S3 TargetNothing: there are no objects.
Apache Kafka TargetNothing: there are no objects.

The steps, and the privileges they need, are in Database Privileges. Removing an Apply Process deletes only its own rows in the checkpoint tables (see Remove Process).

Command line (repcli)

repcli remove database={source|target} dbtype={oracle|mssql|postgresql|mysql|snowflake|redshift|s3} \
[connection parameters of the database] \
[other parameters of the database]
ParameterDescription
databaseThe role of the database: source or target. Required.
dbtypeThe type of the database: mssql, oracle, mysql or postgresql for a Source Database, oracle, mssql, postgresql, mysql, snowflake, redshift or s3 for a Target Database. Required.
server, port, user, password, dbname and the other connection parametersHow to reach the database. They depend on the database: SQL Server as Source, Oracle as Source, MySQL as Source, PostgreSQL as Source, Oracle as Target, SQL Server as Target, PostgreSQL as Target, MySQL as Target, Snowflake as Target, Redshift as Target, AWS S3 as Target and Kafka as Target.

Remove the objects from a SQL Server Source Database. The database is not prepared afterwards:

repcli remove database=source dbtype=mssql server=db-src.example.com port=1433 dbname=testDB user=repuser password=Passw0rd123
[Completed]: Capture objects have been removed [db-src.example.com:1433,testDB]
repcli validate database=source dbtype=mssql server=db-src.example.com port=1433 dbname=testDB user=repuser password=Passw0rd123
[Invalid]: Database is not prepared for capture: [CDC is not enabled: 1]

Remove the objects from a SQL Server Target Database:

repcli remove database=target dbtype=mssql server=db-tgt.example.com port=1433 dbname=testDB user=repuser password=Passw0rd123
[Completed]: Apply objects have been removed [db-tgt.example.com:1433,testDB]
repcli validate database=target dbtype=mssql server=db-tgt.example.com port=1433 dbname=testDB user=repuser password=Passw0rd123
[Invalid]: Database is not prepared for apply: [repi schema does not exist: 1]

For AWS S3 and Apache Kafka the command does nothing:

repcli remove database=target dbtype=s3 s3.region=eu-west-1
[In Process]: Command [REMOVE] has been sent. Use [validate] command to validate the state
repcli remove database=target dbtype=kafka server=kafka1.example.com:9092
[In Process]: Command [REMOVE] has been sent. Use [validate] command to validate the state

REST API

  • Endpoint: https://repstance_url/configure/database
  • Method: POST
  • Header: Content-Type: application/json and X-Token: token

The body of the request:

{
  "command": "remove",
  "parameters": [
    ["database", "source"],
    ["dbtype", "mssql"],
    ["server", "db-src.example.com"],
    ["port", "1433"],
    ["user", "repuser"],
    ["password", "Passw0rd123"],
    ["dbname", "testDB"]
  ]
}

The body of the answer:

{
  "Status": "Completed",
  "Message": "Capture objects have been removed [db-src.example.com:1433,testDB]"
}
HTTP codeMeaning
200The request is valid and the command has been carried out. The body has the status Completed or Failed (prepare and remove) or Valid or Invalid (validate), and the message. A command that cannot do its work, for example because the database cannot be reached, is also answered with 200 and the status Failed or Invalid: always read the status.
401The token is invalid.
422The request cannot be carried out: the JSON, the command or a parameter is wrong. The body has the status Failed and the message, for example Missed port parameter.

Web UI

Click “Cleanup Repstance Objects” in the dialog “Database Settings” of a Capture Process or an Apply Process. The button works on the database that is entered in the dialog and acts at once: there is no confirmation. Use it only for a database that no process needs. The result is shown under the buttons:

Web UI, Database Settings: Completed, Capture objects removed, Cleanup Repstance Objects highlighted
 

The Web UI can clean up only the database that is entered in the dialog. The removal of a replication configuration is described in Remove Replication Configuration.