ORA-02266: Unique/Primary Keys In Table Referenced While Truncating Table

 



Trying to do a data only import into a table and hitting the error below :

ORA-39120: Table "XYZ"."LOOKUPS" can't be truncated, data will be skipped. Failing error is:

ORA-02266: unique/primary keys in table referenced by enabled foreign keys

The primary key in the table( which we are truncating) , seems to be referring to a another child table with foreign key.

Run below script to get the parent table , child table relation



set lines 200

COL CHILD_TABLE FOR a50
col CONSTRAINT_NAME for a50
col owner form a40
col FK_column form a40
col table_name form a50

select b.owner, b.table_name child_table,  c.column_name FK_column, b.constraint_name
    from dba_constraints a, dba_constraints b, dba_cons_columns c
    where a.owner=b.r_owner
    and b.owner=c.owner
    and b.table_name=c.table_name
    and b.constraint_name=c.constraint_name
    and a.constraint_name=b.r_constraint_name
    and b.constraint_type='R'
  and a.owner='&owner'
   and a.table_name='&table_name'
  and a.CONSTRAINT_TYPE='P'


Enter the values and then do a manual - alter table disable constraint.

For tables with multiple constraints this is easier i.e.
  
 select 'alter table ' || owner || '.' || table_name || ' disable constraint ' || constraint_name ||';' stmt from all_constraints
  where r_constraint_name in (select constraint_name from all_constraints where table_name = 'LOOKUPS')

Run the output - remember to enable the constraints when complete - the db I was doing this was restricted so no issue of any others "hitting" the tables.

Import should now work.

Oracle PDB cloning in OCI with RAC / TDE and DataGuard enabled

 

Oracle PDB cloning in OCI with RAC / TDE and DataGuard enabled

Doc ID 1916648.1

https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=339297523964641&id=1916648.1&_afrWindowMode=0&_adf.ctrl-state=5cqsp6ypb_4#aref_section24

 Worthwhile as there are lots of pitfalls , basically DG breaks unless handled correctly.

 This non oracle guide is useful as well if you find it has broken.

https://database-heartbeat.com/2020/12/31/create-pdbs-in-a-data-guard-environment-with-tde-enabled/

New user - linux password issue

 

Hit a problem today changing  a new user password today in Linux.

[root@prd01oua-dbg2 ~]# passwd emcadm

Changing password for user emcadm.

passwd: Authentication token manipulation error

[root@prd01oua-dbg2 pam.d]# ls -ls system-auth

4 -rw-r--r-- 1 root root 1205 Feb  2 10:51 system-auth

In system.auth

password    requisite     pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=

#password    sufficient    pam_unix.so md5 shadow nullok try_first_pass use_authtok

password    required      pam_deny.so

change to

password    requisite     pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=

password    sufficient    pam_unix.so md5 shadow nullok try_first_pass use_authtok

password    required      pam_deny.so

Next we hit a password length problem

[root@prd01oua-dbg2 pam.d]# passwd emcadm

Changing password for user emcadm.

New password:

BAD PASSWORD: The password is shorter than 15 characters

/etc/security/pwquality.conf

# Password Minimum Length should be configured

minlen=8

 

Changing password for user emcadm.

New password:

Retype new password:

passwd: all authentication tokens updated successfully.

[root@prd01oua-dbg1 security]#

Et voilla.....