Wednesday, June 17, 2020

How to extend Linux file system after increasing my EBS volume on my EC2 instance



How to extend Linux file system after increasing my EBS volume on my EC2 instance


[root@anurag ~]#
[root@anurag ~]#
[root@anurag ~]# lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  10G  0 disk
├─xvda1 202:1    0   1M  0 part
└─xvda2 202:2    0  10G  0 part /
xvdb    202:16   0  20G  0 disk /u01/oracle
xvdc    202:32   0  20G  0 disk /u01/oradata
xvdd    202:48   0   8G  0 disk /u01/FRA
[root@anurag ~]#
[root@anurag ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        1.9G     0  1.9G   0% /dev
tmpfs           1.9G     0  1.9G   0% /dev/shm
tmpfs           1.9G   17M  1.9G   1% /run
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/xvda2       10G  4.3G  5.7G  44% /
/dev/xvdc       7.9G  5.8G  1.7G  78% /u01/oradata
/dev/xvdd       7.9G  1.5G  6.0G  20% /u01/FRA
/dev/xvdb       7.9G  7.4G     0 100% /u01/oracle
tmpfs           378M     0  378M   0% /run/user/1002
tmpfs           378M     0  378M   0% /run/user/1000
[root@anurag ~]#
[root@anurag ~]#
[root@anurag ~]# resize2fs /dev/xvdb
resize2fs 1.45.4 (23-Sep-2019)
Filesystem at /dev/xvdb is mounted on /u01/oracle; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 3
The filesystem on /dev/xvdb is now 5242880 (4k) blocks long.

[root@anurag ~]#
[root@anurag ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        1.9G     0  1.9G   0% /dev
tmpfs           1.9G     0  1.9G   0% /dev/shm
tmpfs           1.9G   17M  1.9G   1% /run
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/xvda2       10G  4.3G  5.7G  44% /
/dev/xvdc       7.9G  5.8G  1.7G  78% /u01/oradata
/dev/xvdd       7.9G  1.5G  6.0G  20% /u01/FRA
/dev/xvdb        20G  7.5G   12G  40% /u01/oracle
tmpfs           378M     0  378M   0% /run/user/1002
tmpfs           378M     0  378M   0% /run/user/1000
[root@anurag ~]#
[root@anurag ~]# resize2fs /dev/xvdc
resize2fs 1.45.4 (23-Sep-2019)
Filesystem at /dev/xvdc is mounted on /u01/oradata; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 3
The filesystem on /dev/xvdc is now 5242880 (4k) blocks long.

[root@anurag ~]#
[root@anurag ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        1.9G     0  1.9G   0% /dev
tmpfs           1.9G     0  1.9G   0% /dev/shm
tmpfs           1.9G   17M  1.9G   1% /run
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/xvda2       10G  4.3G  5.7G  44% /
/dev/xvdc        20G  5.8G   14G  31% /u01/oradata
/dev/xvdd       7.9G  1.5G  6.0G  20% /u01/FRA
/dev/xvdb        20G  7.5G   12G  40% /u01/oracle
tmpfs           378M     0  378M   0% /run/user/1002
tmpfs           378M     0  378M   0% /run/user/1000
[root@anurag ~]#
[root@anurag ~]#

Wednesday, June 10, 2020

How to check DML operations oracle


check dml operations oracle



SQL> exec dbms_stats.gather_table_stats(ownname=>'TEST',tabname=>'TEST_1')

PL/SQL procedure successfully completed.

SQL> exec DBMS_STATS.FLUSH_DATABASE_MONITORING_INFO;

SQL>
SQL>
SQL> select table_name,inserts,updates,deletes,truncated,timestamp from sys.dba_tab_modifications where table_owner='TEST' and table_name= 'TEST_1'
  2  ;

no rows selected

SQL>
SQL> insert  into test.test_1 select * from dba_objects;

73824 rows created.

SQL> /

73824 rows created.

SQL> commit;

Commit complete.

SQL> select table_name,inserts,updates,deletes,truncated,timestamp from sys.dba_tab_modifications where table_owner='TEST' and table_name= 'TEST_1';

TABLE_NAME                        INSERTS    UPDATES    DELETES TRU TIMESTAMP
------------------------------ ---------- ---------- ---------- --- ---------
TEST_1                             147648          0          0 NO

SQL>

Query to list Unindexed Foreign Keys



Query to get Unindexed Foreign Keys 


undefine schema_owner
set pagesize 5000
set linesize 350
column status format a10
column table_name format a30
column fk_name format a30
column fk_columns format a30
column index_name format a30
column index_columns format a30


select
      case
        when i.index_name is not null then
          'indexed'
        else
          'unindexed'
       end                  as status
      ,c.table_name         as table_name
      ,c.constraint_name    as fk_name
      ,c.fk_columns         as fk_columns
      ,i.index_name         as index_name
      ,i.index_columns      as index_columns
from
    (
      select  a.table_name
             ,a.constraint_name
             ,listagg(b.column_name, ' ' )
              within group (order by column_name) as fk_columns
      from
              dba_constraints a
             ,dba_cons_columns b
      where
              a.constraint_name = b.constraint_name
      and     a.constraint_type = 'R'
      and     a.owner           = b.owner
      and     a.owner           = '&&schema_owner'
      group by
              a.table_name
             ,a.constraint_name
    ) c
left outer join
  (
    select  table_name
           ,index_name
           ,cr
           ,listagg(column_name, ' ')
            within group (order by column_name) as index_columns
    from
        (
          select
                  table_name
                 ,index_name
                 ,column_position
                 ,column_name
                 ,connect_by_root(column_name) cr
          from
                  dba_ind_columns
          where
                  index_owner               = '&&schema_owner'
          connect
                 by prior column_position-1 = column_position
                 and prior index_name       = index_name
         )
    group by table_name
            ,index_name, cr
  ) i
      on c.fk_columns = i.index_columns
     and c.table_name = i.table_name;





SQL> undefine schema_owner
set pagesize 5000
set linesize 350
column status format a10
column table_name format a30
column fk_name format a30
SQL> SQL> SQL> SQL> SQL> SQL> column fk_columns format a30
column index_name format a30
column index_columns format a30


select
SQL> SQL> SQL> SQL> SQL>   2        case
        when i.index_name is not null then
          'indexed'
        else
          'unindexed'
       end                  as status
  3    4    5    6    7    8        ,c.table_name         as table_name
      ,c.constraint_name    as fk_name
      ,c.fk_columns         as fk_columns
      ,i.index_name         as index_name
      ,i.index_columns      as index_columns
  9   10   11   12   13  from
    (
      select  a.table_name
             ,a.constraint_name
             ,listagg(b.column_name, ' ' )
 14   15   16   17   18                within group (order by column_name) as fk_columns
      from
              dba_constraints a
 19   20   21               ,dba_cons_columns b
      where
              a.constraint_name = b.constraint_name
      and     a.constraint_type = 'R'
 22   23   24   25        and     a.owner           = b.owner
      and     a.owner           = '&&schema_owner'
 26   27        group by
 28                a.table_name
             ,a.constraint_name
    ) c
 29   30   31  left outer join
  (
    select  table_name
           ,index_name
           ,cr
 32   33   34   35   36             ,listagg(column_name, ' ')
            within group (order by column_name) as index_columns
    from
 37   38   39          (
 40            select
                  table_name
                 ,index_name
                 ,column_position
                 ,column_name
                 ,connect_by_root(column_name) cr
          from
 41   42   43   44   45   46   47                    dba_ind_columns
          where
                  index_owner               = '&&schema_owner'
          connect
                 by prior column_position-1 = column_position
                 and prior index_name       = index_name
 48           )
    group by table_name
            ,index_name, cr
 49   50   51   52   53   54   55   56    ) i
      on c.fk_columns = i.index_columns
     and c.table_name = i.table_name; 57   58
Enter value for schema_owner: HR
old  26:       and     a.owner           = '&&schema_owner'
new  26:       and     a.owner           = 'HR'
old  49:                   index_owner               = '&&schema_owner'
new  49:                   index_owner               = 'HR'

STATUS     TABLE_NAME                     FK_NAME                        FK_COLUMNS                     INDEX_NAME                     IN                       DEX_COLUMNS
---------- ------------------------------ ---------------  ------- ------------------------------ ----------------       ---------------        --------------                    
indexed    EMPLOYEES                      EMP_JOB_FK                     JOB_ID                         EMP_JOB_IX                     JO                       B_ID
indexed    EMPLOYEES                      EMP_MANAGER_FK                 MANAGER_ID                     EMP_MANAGER_IX                 MA                       NAGER_ID
indexed    EMPLOYEES                      EMP_DEPT_FK                    DEPARTMENT_ID                  EMP_DEPARTMENT_IX              DE                       PARTMENT_ID
indexed    LOCATIONS                      LOC_C_ID_FK                    COUNTRY_ID                     LOC_COUNTRY_IX                 CO                       UNTRY_ID
indexed    DEPARTMENTS                    DEPT_LOC_FK                    LOCATION_ID                    DEPT_LOCATION_IX               LO                       CATION_ID
indexed    JOB_HISTORY                    JHIST_JOB_FK                   JOB_ID                         JHIST_JOB_IX                   JO                       B_ID
indexed    JOB_HISTORY                    JHIST_EMP_FK                   EMPLOYEE_ID                    JHIST_EMPLOYEE_IX              EM                       PLOYEE_ID
indexed    JOB_HISTORY                    JHIST_DEPT_FK                  DEPARTMENT_ID                  JHIST_DEPARTMENT_IX            DE                       PARTMENT_ID
indexed    JOB_HISTORY                    JHIST_EMP_FK                   EMPLOYEE_ID                    JHIST_EMP_ID_ST_DATE_PK        EM                       PLOYEE_ID
unindexed  DEPARTMENTS                    DEPT_MGR_FK                    MANAGER_ID
unindexed  COUNTRIES                      COUNTR_REG_FK                  REGION_ID

11 rows selected.

SQL>

Complex Oracle 19c to PostgreSQL 15 Database Migration

Production-oriented migration approach for a complex Oracle 19c to PostgreSQL 15 workload , covering assessment, schema and code conversion,...