Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » SQL Anywhere 服务器 - SQL 的用法 » 监控和提高数据库性能 » 应用程序分析教程 » 教程:诊断索引碎片

 

第 1 课:建立索引碎片

本教程假定您已创建了测试数据库。如果尚未创建测试数据库,请参见第 1 课:创建测试数据库

提示

可以将本教程中的 SQL 语句复制并粘贴到 Interactive SQL 中。

♦  建立索引碎片
  1. 启动 Sybase Central,并使用用户 ID DBA 和口令 sql 连接到测试数据库 app_profiling.db

    如果不熟悉如何启动 Sybase Central 和连接到数据库,请参见连接到本地数据库

  2. 在左窗格中,选择 app_profiling - DBA 数据库,然后选择 [文件] » [打开 Interactive SQL]。

    Interactive SQL 启动并连接到 app_profiling - DBA 数据库。

  3. 在 Interactive SQL 中,运行以下 SQL 语句以引入索引碎片。这些语句可能需要几分钟来完成。

    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. 退出 Interactive SQL。