{{ To connect any database which is on another machine in network we need to give an tns entry over tnsnames.ora file
then connect to that database from cmd with command "sqlplus sys/manager@<connection string> as sysdba" }}
when table is not available(the issue attached with)
EXEC DBMS_STATS.GATHER_TABLE_STATS ('<schema name>', 'table name');
(To get schema name query
SQL>select table_name,owner from dba_tables where table_name='';)
SQL> desc dba_users;
Name Null? Type
----------------------------------------- -------- ----------------------------
USERNAME NOT NULL VARCHAR2(30)
USER_ID NOT NULL NUMBER
PASSWORD VARCHAR2(30)
ACCOUNT_STATUS NOT NULL VARCHAR2(32)
LOCK_DATE DATE
EXPIRY_DATE DATE
DEFAULT_TABLESPACE NOT NULL VARCHAR2(30)
TEMPORARY_TABLESPACE NOT NULL VARCHAR2(30)
CREATED NOT NULL DATE
PROFILE NOT NULL VARCHAR2(30)
INITIAL_RSRC_CONSUMER_GROUP VARCHAR2(30)
EXTERNAL_NAME VARCHAR2(4000)
PASSWORD_VERSIONS VARCHAR2(8)
EDITIONS_ENABLED VARCHAR2(1)
SQL> select owner,table_name from dba_tables where table_name ='PS_RETIREMENT_NF
';
OWNER
--------------------------------------------------------------------------------
TABLE_NAME
--------------------------------------------------------------------------------
SYSADM
PS_RETIREMENT_NF
SQL> sho user
USER is "SYS"
S^C
C:\Documents and Settings\psftuser>EXEC DBMS_STATS.GATHER_TABLE_S
'EXEC' is not recognized as an internal or external command,
operable program or batch file.
C:\Documents and Settings\psftuser>
C:\Documents and Settings\psftuser>\
'\' is not recognized as an internal or external command,
operable program or batch file.
C:\Documents and Settings\psftuser>
C:\Documents and Settings\psftuser>
C:\Documents and Settings\psftuser>
C:\Documents and Settings\psftuser>
C:\Documents and Settings\psftuser>
C:\Documents and Settings\psftuser>sqlplus
SQL*Plus: Release 11.1.0.6.0 - Production on Mon Nov 5 06:40:24 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Enter user-name: / as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning and OLAP options
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SYSADM','PS_RETIREMENT_NF');
PL/SQL procedure successfully completed.
SQL> select table_name,last_analyzed from dba_tables where table_name ='PS_RETI
REMENT_NF';
TABLE_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_RETIREMENT_NF
05-NOV-12
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SYSADM','PS_AM_ADD_ATT');
PL/SQL procedure successfully completed.
SQL> select table_name,last_analyzed from dba_tables where table_name ='PS_AM_AD
D_ATT';
TABLE_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_AM_ADD_ATT
05-NOV-12
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SYSADM','PS_AM_VAT_ATTR_H');
PL/SQL procedure successfully completed.
SQL> select table_name,last_analyzed from dba_tables where table_name ='PS_AM_VA
T_ATTR_H';
TABLE_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_AM_VAT_ATTR_H
05-NOV-12
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SYSADM','PS_AM_VAT_ATTR_L1');
PL/SQL procedure successfully completed.
SQL> select table_name,last_analyzed from dba_tables where table_name ='PS_AM_VA
T_ATTR_L1';
TABLE_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_AM_VAT_ATTR_L1
05-NOV-12
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SYSADM','PS_BOOK_TAX_CR');
PL/SQL procedure successfully completed.
SQL> select table_name,last_analyzed from dba_tables where table_name ='PS_BOOK_
TAX_CR';
TABLE_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_BOOK_TAX_CR
05-NOV-12
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SYSADM','PS_LEASE_SCHED2');
PL/SQL procedure successfully completed.
SQL> select table_name,last_analyzed from dba_tables where table_name ='PS_LEAS
E_SCHED2';
TABLE_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_LEASE_SCHED2
05-NOV-12
SQL> DESC DBA_INDEXES;
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER NOT NULL VARCHAR2(30)
INDEX_NAME NOT NULL VARCHAR2(30)
INDEX_TYPE VARCHAR2(27)
TABLE_OWNER NOT NULL VARCHAR2(30)
TABLE_NAME NOT NULL VARCHAR2(30)
TABLE_TYPE VARCHAR2(11)
UNIQUENESS VARCHAR2(9)
COMPRESSION VARCHAR2(8)
PREFIX_LENGTH NUMBER
TABLESPACE_NAME VARCHAR2(30)
INI_TRANS NUMBER
MAX_TRANS NUMBER
INITIAL_EXTENT NUMBER
NEXT_EXTENT NUMBER
MIN_EXTENTS NUMBER
MAX_EXTENTS NUMBER
PCT_INCREASE NUMBER
PCT_THRESHOLD NUMBER
INCLUDE_COLUMN NUMBER
FREELISTS NUMBER
FREELIST_GROUPS NUMBER
PCT_FREE NUMBER
LOGGING VARCHAR2(3)
BLEVEL NUMBER
LEAF_BLOCKS NUMBER
DISTINCT_KEYS NUMBER
AVG_LEAF_BLOCKS_PER_KEY NUMBER
AVG_DATA_BLOCKS_PER_KEY NUMBER
CLUSTERING_FACTOR NUMBER
STATUS VARCHAR2(8)
NUM_ROWS NUMBER
SAMPLE_SIZE NUMBER
LAST_ANALYZED DATE
DEGREE VARCHAR2(40)
INSTANCES VARCHAR2(40)
PARTITIONED VARCHAR2(3)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
BUFFER_POOL VARCHAR2(7)
USER_STATS VARCHAR2(3)
DURATION VARCHAR2(15)
PCT_DIRECT_ACCESS NUMBER
ITYP_OWNER VARCHAR2(30)
ITYP_NAME VARCHAR2(30)
PARAMETERS VARCHAR2(1000)
GLOBAL_STATS VARCHAR2(3)
DOMIDX_STATUS VARCHAR2(12)
DOMIDX_OPSTATUS VARCHAR2(6)
FUNCIDX_STATUS VARCHAR2(8)
JOIN_INDEX VARCHAR2(3)
IOT_REDUNDANT_PKEY_ELIM VARCHAR2(3)
DROPPED VARCHAR2(3)
VISIBILITY VARCHAR2(9)
DOMIDX_MANAGEMENT VARCHAR2(14)
SQL> select INDEX_NAME,LAST_ANALYZED from dba_indexes where index_name='PS_RETI
REMENT_NF';
INDEX_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_RETIREMENT_NF
05-NOV-12
SQL> select INDEX_NAME,LAST_ANALYZED from dba_indexes where index_name='PS_LEAS
E_SCHED2';
INDEX_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_LEASE_SCHED2
05-NOV-12
SQL>
then connect to that database from cmd with command "sqlplus sys/manager@<connection string> as sysdba" }}
when table is not available(the issue attached with)
EXEC DBMS_STATS.GATHER_TABLE_STATS ('<schema name>', 'table name');
(To get schema name query
SQL>select table_name,owner from dba_tables where table_name='';)
SQL> desc dba_users;
Name Null? Type
----------------------------------------- -------- ----------------------------
USERNAME NOT NULL VARCHAR2(30)
USER_ID NOT NULL NUMBER
PASSWORD VARCHAR2(30)
ACCOUNT_STATUS NOT NULL VARCHAR2(32)
LOCK_DATE DATE
EXPIRY_DATE DATE
DEFAULT_TABLESPACE NOT NULL VARCHAR2(30)
TEMPORARY_TABLESPACE NOT NULL VARCHAR2(30)
CREATED NOT NULL DATE
PROFILE NOT NULL VARCHAR2(30)
INITIAL_RSRC_CONSUMER_GROUP VARCHAR2(30)
EXTERNAL_NAME VARCHAR2(4000)
PASSWORD_VERSIONS VARCHAR2(8)
EDITIONS_ENABLED VARCHAR2(1)
SQL> select owner,table_name from dba_tables where table_name ='PS_RETIREMENT_NF
';
OWNER
--------------------------------------------------------------------------------
TABLE_NAME
--------------------------------------------------------------------------------
SYSADM
PS_RETIREMENT_NF
SQL> sho user
USER is "SYS"
S^C
C:\Documents and Settings\psftuser>EXEC DBMS_STATS.GATHER_TABLE_S
'EXEC' is not recognized as an internal or external command,
operable program or batch file.
C:\Documents and Settings\psftuser>
C:\Documents and Settings\psftuser>\
'\' is not recognized as an internal or external command,
operable program or batch file.
C:\Documents and Settings\psftuser>
C:\Documents and Settings\psftuser>
C:\Documents and Settings\psftuser>
C:\Documents and Settings\psftuser>
C:\Documents and Settings\psftuser>
C:\Documents and Settings\psftuser>sqlplus
SQL*Plus: Release 11.1.0.6.0 - Production on Mon Nov 5 06:40:24 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Enter user-name: / as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning and OLAP options
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SYSADM','PS_RETIREMENT_NF');
PL/SQL procedure successfully completed.
SQL> select table_name,last_analyzed from dba_tables where table_name ='PS_RETI
REMENT_NF';
TABLE_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_RETIREMENT_NF
05-NOV-12
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SYSADM','PS_AM_ADD_ATT');
PL/SQL procedure successfully completed.
SQL> select table_name,last_analyzed from dba_tables where table_name ='PS_AM_AD
D_ATT';
TABLE_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_AM_ADD_ATT
05-NOV-12
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SYSADM','PS_AM_VAT_ATTR_H');
PL/SQL procedure successfully completed.
SQL> select table_name,last_analyzed from dba_tables where table_name ='PS_AM_VA
T_ATTR_H';
TABLE_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_AM_VAT_ATTR_H
05-NOV-12
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SYSADM','PS_AM_VAT_ATTR_L1');
PL/SQL procedure successfully completed.
SQL> select table_name,last_analyzed from dba_tables where table_name ='PS_AM_VA
T_ATTR_L1';
TABLE_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_AM_VAT_ATTR_L1
05-NOV-12
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SYSADM','PS_BOOK_TAX_CR');
PL/SQL procedure successfully completed.
SQL> select table_name,last_analyzed from dba_tables where table_name ='PS_BOOK_
TAX_CR';
TABLE_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_BOOK_TAX_CR
05-NOV-12
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SYSADM','PS_LEASE_SCHED2');
PL/SQL procedure successfully completed.
SQL> select table_name,last_analyzed from dba_tables where table_name ='PS_LEAS
E_SCHED2';
TABLE_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_LEASE_SCHED2
05-NOV-12
SQL> DESC DBA_INDEXES;
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER NOT NULL VARCHAR2(30)
INDEX_NAME NOT NULL VARCHAR2(30)
INDEX_TYPE VARCHAR2(27)
TABLE_OWNER NOT NULL VARCHAR2(30)
TABLE_NAME NOT NULL VARCHAR2(30)
TABLE_TYPE VARCHAR2(11)
UNIQUENESS VARCHAR2(9)
COMPRESSION VARCHAR2(8)
PREFIX_LENGTH NUMBER
TABLESPACE_NAME VARCHAR2(30)
INI_TRANS NUMBER
MAX_TRANS NUMBER
INITIAL_EXTENT NUMBER
NEXT_EXTENT NUMBER
MIN_EXTENTS NUMBER
MAX_EXTENTS NUMBER
PCT_INCREASE NUMBER
PCT_THRESHOLD NUMBER
INCLUDE_COLUMN NUMBER
FREELISTS NUMBER
FREELIST_GROUPS NUMBER
PCT_FREE NUMBER
LOGGING VARCHAR2(3)
BLEVEL NUMBER
LEAF_BLOCKS NUMBER
DISTINCT_KEYS NUMBER
AVG_LEAF_BLOCKS_PER_KEY NUMBER
AVG_DATA_BLOCKS_PER_KEY NUMBER
CLUSTERING_FACTOR NUMBER
STATUS VARCHAR2(8)
NUM_ROWS NUMBER
SAMPLE_SIZE NUMBER
LAST_ANALYZED DATE
DEGREE VARCHAR2(40)
INSTANCES VARCHAR2(40)
PARTITIONED VARCHAR2(3)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
BUFFER_POOL VARCHAR2(7)
USER_STATS VARCHAR2(3)
DURATION VARCHAR2(15)
PCT_DIRECT_ACCESS NUMBER
ITYP_OWNER VARCHAR2(30)
ITYP_NAME VARCHAR2(30)
PARAMETERS VARCHAR2(1000)
GLOBAL_STATS VARCHAR2(3)
DOMIDX_STATUS VARCHAR2(12)
DOMIDX_OPSTATUS VARCHAR2(6)
FUNCIDX_STATUS VARCHAR2(8)
JOIN_INDEX VARCHAR2(3)
IOT_REDUNDANT_PKEY_ELIM VARCHAR2(3)
DROPPED VARCHAR2(3)
VISIBILITY VARCHAR2(9)
DOMIDX_MANAGEMENT VARCHAR2(14)
SQL> select INDEX_NAME,LAST_ANALYZED from dba_indexes where index_name='PS_RETI
REMENT_NF';
INDEX_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_RETIREMENT_NF
05-NOV-12
SQL> select INDEX_NAME,LAST_ANALYZED from dba_indexes where index_name='PS_LEAS
E_SCHED2';
INDEX_NAME
--------------------------------------------------------------------------------
LAST_ANALYZED
---------------
PS_LEASE_SCHED2
05-NOV-12
SQL>
No comments:
Post a Comment