云数据库 GAUSSDB-CREATE INDEX:语法格式

时间:2024-11-13 14:46:21

语法格式

  • 在表上创建索引。
    1
    2
    3
    4
    5
    6
    7
    8
    CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ IF NOT EXISTS ] [ [schema_name.] index_name ] ON table_name [ USING method ]
        ({ { column_name [ ( length ) ] | ( expression ) } [ COLLATE collation ] [ opclass ] [ ASC | DESC ] [ NULLS { FIRST | LAST } ] }[, ...] )
        [ INCLUDE ( column_name [, ...] ) ]
        [ WITH ( {storage_parameter = value} [, ... ] ) ]
        [ TABLESPACE tablespace_name ] 
        { [ COMMENT 'string' ] [ ... ] }
        [ { VISIBLE | INVISIBLE } ]
        [ WHERE predicate ];
    
  • 在分区表上创建索引。
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [schema_name.] index_name ] ON table_name [ USING method ]
        ( { { column_name [ ( length ) ] | ( expression ) } [ COLLATE collation ] [ opclass ] [ ASC | DESC ] [ NULLS LAST ] } [, ...] )
        [ LOCAL
            [ ( { PARTITION index_partition_name [ FOR { partition_name | ( partition_value [, ...] ) } ] [ TABLESPACE index_partition_tablespace ]
                    [ ( [SUBPARTITION index_subpartition_name] [ FOR { partition_name | ( partition_value [, ...] ) } ]  [ TABLESPACE index_partition_tablespace ]
                        [, ...] ) ]
                [, ...] } ) ]
            | GLOBAL ]
        [ INCLUDE ( column_name [, ...] ) ]
        [ WITH ( { storage_parameter = value } [, ...] ) ]
        [ TABLESPACE tablespace_name ] 
        { [ COMMENT 'string' ] [ ... ] }
        [ { VISIBLE | INVISIBLE } ];
    
support.huaweicloud.com/distributed-devg-v8-gaussdb/gaussdb-12-0549.html