Examples of IndexStatsUtil


Examples of org.apache.derbyTesting.junit.IndexStatsUtil

     *  SYSCS_DROP_STATISTICS and SYSCS_UPDATE_STATISTICS
     */
    public void testIndexAndColumnNamedStatistics() throws SQLException {
        String tbl = "T1";
        // Helper object to obtain information about index statistics.
        IndexStatsUtil stats = new IndexStatsUtil(openDefaultConnection());
        Statement s = createStatement();

        // Get the initial count of statistics in the database.
        int initialStatsCount = stats.getStats().length;

        //Notice the name of one of the columns is STATISTICS
        s.executeUpdate("CREATE TABLE t1 (c11 int, statistics int not null)");
        //Notice that the name of the index is STATISTICS which is same as
        // one of the column names
        s.executeUpdate("CREATE INDEX statistIcs ON t1(c11)");
        s.executeUpdate("INSERT INTO t1 VALUES(1,1)");
        stats.assertNoStatsTable(tbl);
        //Drop the column named STATISTICS and make sure parser doesn't
        // throw an error
        s.executeUpdate("ALTER TABLE t1 DROP statistics");
        //Should still be able to call update/drop statistics on index
        // STATISTICS
        s.executeUpdate("CALL SYSCS_UTIL.SYSCS_UPDATE_STATISTICS('APP','T1','STATISTICS')");
        stats.assertTableStats(tbl, 1);
        s.executeUpdate("CALL SYSCS_UTIL.SYSCS_DROP_STATISTICS('APP','T1','STATISTICS')");
        stats.assertNoStatsTable(tbl);
        //Add the column named STATISTICS back
        s.executeUpdate("ALTER TABLE t1 ADD COLUMN statistics int");
        stats.assertNoStatsTable(tbl);
        //Update or drop statistics for index named STATISTICS. Note that there
        // is also a column named STATISTICS in the table
        s.executeUpdate("CALL SYSCS_UTIL.SYSCS_DROP_STATISTICS('APP','T1','STATISTICS')");
        stats.assertNoStatsTable(tbl);
        s.executeUpdate("CALL SYSCS_UTIL.SYSCS_UPDATE_STATISTICS('APP','T1','STATISTICS')");
        stats.assertTableStats(tbl, 1);
        s.executeUpdate("DROP TABLE t1");

        // Check that we haven't created some other statistics as a side-effect.
        assertEquals(initialStatsCount, stats.getStats().length);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.