Lesson 1: Setting up index fragmentation

This tutorial assumes you have created the test database. If you have not, see Lesson 1: Creating the test database.

Tip

You can copy and paste the SQL statements in this tutorial into Interactive SQL.

To set up index fragmentation
  1. Start Sybase Central and connect to the test database app_profiling.db with the user ID DBA and the password sql.

    If you are unfamiliar with starting Sybase Central and connecting to a database, see Connect to a local database.

  2. In the left pane, select the app_profiling - DBA database, and then choose File » Open Interactive SQL.

    Interactive SQL starts and connects to the app_profiling - DBA database.

  3. In Interactive SQL, run the following SQL statements to introduce index fragmentation. These statements can take a few minutes to complete.

    CREATE TABLE fragment ( id INT );
    CREATE INDEX idx_fragment ON fragment ( id );
    INSERT INTO fragment SELECT * FROM sa_rowgenerator ( 0, 100000 );
    DELETE FROM fragment WHERE MOD ( id, 2 ) = 0;
    INSERT INTO fragment SELECT * FROM sa_rowgenerator ( 0, 100000 );
    INSERT INTO fragment SELECT * FROM sa_rowgenerator ( 0, 100000 );
    COMMIT;
  4. Exit Interactive SQL.