How do you delete unwanted domains using SQL?

Document ID : KB000027871
Last Modified Date : 14/02/2018
Show Technical Document Details

Question:

How to delete unwanted domains without having to go through the RC/Secure online panels using SQL?

Answer:

The following SQL can be used to delete any user and/or application domains from the RC/SECURE SRS DB2 tables 1 at a time. Down lower SQL is included that will delete multiple domains in each DELETE SQL statement if that's what is needed:

  1. Delete 1 domain at a time:
      DELETE FROM PTI.PTRCS_USRDOM_0200   WHERE NAME = 'user domain'     AND DB2ID = 'xxxx';         DELETE FROM PTI.PTRCS_APLDOM_0200   WHERE NAME = 'appl domain'   DELETE FROM PTI.PTRCS_APLCOL_0200  WHERE NAME = 'appl domain'  AND DB2ID = 'xxxx';      DELETE FROM PTI.PTRCS_DOMREL_0200 WHERE APPL_DOMAIN = 'appl domain' AND DB2ID = 'xxxx'; DELETE FROM PTI.PTRCS_DOMREL_0200 WHERE USER_DOMAIN = 'user domain' AND DB2ID = 'xxxx'; DELETE FROM PTI.PTRCS_DOMDIR_0200 WHERE NAME = 'user domain'  AND DB2ID = 'xxxx';     DELETE FROM PTI.PTRCS_DOMDIR_0200 WHERE NAME = 'appl domain'   AND DB2ID = 'xxxx';
  2. Delete multiple domains with 1 SQL DELETE statement:
      DELETE FROM PTI.PTRCS_USRDOM_0200   WHERE NAME IN ('user domain1','user domain2',...)   AND DB2ID = 'xxxx';       DELETE FROM PTI.PTRCS_APLDOM_0200     WHERE NAME IN ('appl domain1','appl domain2',...)    AND DB2ID = 'xxxx';                DELETE FROM PTI.PTRCS_APLCOL_0200   WHERE NAME IN ('appl domain1','appl domain2',...)    AND DB2ID = 'xxxx';                 DELETE FROM PTI.PTRCS_DOMREL_0200   WHERE APPL_DOMAIN IN ('appl domain1','appl domain2',...)   AND DB2ID = 'xxxx';  DELETE FROM PTI.PTRCS_DOMREL_0200  WHERE USER_DOMAIN IN ('user domain1','user domain2',...)   AND DB2ID = 'xxxx';      DELETE FROM PTI.PTRCS_DOMDIR_0200    WHERE NAME IN ('user domain1','user domain2',...)  AND DB2ID = 'xxxx';    DELETE FROM PTI.PTRCS_DOMDIR_0200  WHERE NAME IN ('appl domain1','appl domain2',...)  AND DB2ID = 'xxxx';