Oracle: Statistics Update

Mar 30, 2016 1 min.

Get Last statistics Update SELECTtable_name,last_analyzed,sample_size,num_rowssample_pctFROMdba_tablesWHEREowner='your_schema_name_here'ORDERBYlast_analyzed;Note: last_analyzed column shows the last analyzed date sample_size and sample_pct should be same (or difference should be very less) Statistics Update (for schema) executeDBMS_STATS.GATHER_SCHEMA_STATS(OWNNAME=>'your_schema_name_here',ESTIMATE_PERCENT=>DBMS_STATS.AUTO_SAMPLE_SIZE,METHOD_OPT=>'FOR ALL INDEXED COLUMNS',DEGREE=>8,CASCADE=>TRUE);Statistics Update (for table) EXECDBMS_STATS.GATHER_TABLE_STATS('your_schema_name_here','your_table_name_here',estimate_percent=>'',method_opt=>'for all indexed columns size auto',DEGREE=>8,CASCADE=>TRUE);

Java random integer in min and max range

Mar 4, 2016 1 min.

Following sample code returns a random integer within the give min and max range (both inclusive) import java.util.Random; public class RandomRange { // Declare as class variable so that it is not re-seeded every call private static Random random = new Random(); /** * Returns a psuedo-random number between Min and Max (both inclusive) * @param min Minimim value * @param max Maximim value. Must be greater than min. * @return Integer between min and max (both inclusive) * @see java.

Maven Dependency Updates

Mar 4, 2016 1 min.

Use the following command to find any updates on dependencies mvn versions:display-dependency-updates Sample Output: $ mvn versions:display-dependency-updates [INFO] Scanning for projects... [INFO] [INFO] --------------------< com.sample.myproject:app >-------------------- [INFO] Building MyProject 1.0-SNAPSHOT [INFO] --------------------------------[ war ]--------------------------------- [INFO] [INFO] --- versions-maven-plugin:2.5:display-dependency-updates (default-cli) @ app --- [INFO] artifact commons-io:commons-io: checking for updates from local-release-repository [INFO] artifact commons-fileupload:commons-fileupload: checking for updates from prime-repo [INFO] artifact commons-io:commons-io: checking for updates from local-release-repository [INFO] The following dependencies in Dependencies have newer versions: [INFO] commons-io:commons-io .

Maven Skip Test

Jan 21, 2016 1 min.

Any of the following option can be used to skip the tests during build process. Option 1: -DskipTests Option 2: -DskipTests=true Option 3: -Dmaven.test.skip=true Option 4: -Darguments="-DskipTests"

Oracle Invalid Objects

Jan 20, 2016 1 min.

Get List of Invalid Objects Following query can be used to get the list of Invalid objects. SELECTobject_type,object_nameFROMuser_objectsWHERESTATUS!='VALID'ORDERBYobject_type;or SELECTowner,object_type,object_nameFROMdba_objectsWHERESTATUS!='VALID'ORDERBYowner,object_type;Compile Invalid Objects Following SQL block can be used for compiling invalid objects DECLAREsql_statementvarchar2(500);BEGINdbms_output.put_line(chr(0));dbms_output.put_line('Re-compilation of Invalid Objects');dbms_output.put_line('---------------------------------');dbms_output.put_line(chr(0));FORinvalidin(SELECTobject_type,object_nameFROMuser_objectsoWHEREo.status='INVALID'ANDo.object_typeIN('PACKAGE','PACKAGE BODY','TRIGGER','VIEW','MATERIALIZED VIEW','PROCEDURE')ORDERBYo.object_type)LOOPIFinvalid.object_type='PACKAGE BODY'THENsql_statement:='alter package '||invalid.object_name||' compile body';ELSEsql_statement:='alter '||invalid.object_type||' '||invalid.object_name||' compile';ENDIF;BEGINEXECUTEIMMEDIATEsql_statement;dbms_output.put_line(rpad(initcap(invalid.object_type)||' '||invalid.object_name,32)||' : compiled');EXCEPTIONWHENOTHERSTHENdbms_output.put_line(sqlerrm);END;ENDLOOP;END;/or SETheadingoff;SETfeedbackoff;SETechooff;SETlines999;SPOOLrun_invalid.sqlSELECT'ALTER '||OBJECT_TYPE||' '||OWNER||'.'||OBJECT_NAME||' COMPILE;'FROMdba_objectsWHERESTATUS='INVALID'ANDobject_typeIN('PACKAGE','FUNCTION','PROCEDURE');SPOOLoff;SETheadingon;SETfeedbackon;SETechoon;@run_invalid.sqlor EXECUTL_RECOMP.recomp_serial('schema name');