PrimaryKeyConstraint in sqlparser::ast::table_constraints - Rust

Struct PrimaryKeyConstraint 

Source

pub struct PrimaryKeyConstraint {
    pub name: Option<Ident>,
    pub index_name: Option<Ident>,
    pub index_type: Option<IndexType>,
    pub columns: Vec<IndexColumn>,
    pub index_options: Vec<IndexOption>,
    pub characteristics: Option<ConstraintCharacteristics>,
}
Expand description

MySQL definition for PRIMARY KEY constraints statements:

  • [CONSTRAINT [<name>]] PRIMARY KEY [index_name] [index_type] (<columns>) <index_options>

Actually the specification have no [index_name] but the next query will complete successfully:

CREATE TABLE unspec_table (
  xid INT NOT NULL,
  CONSTRAINT p_name PRIMARY KEY index_name USING BTREE (xid)
);

where:

  • index_type is USING {BTREE | HASH}
  • index_options is {index_type | COMMENT 'string' | ... %currently unsupported stmts% } ...

Constraint name.

Can be not the same as index_name

Index name

Optional USING of index type statement before columns.

§columns: Vec<IndexColumn>

Identifiers of the columns that form the primary key.

Optional index options such as USING.

Optional characteristics like DEFERRABLE.

§
§
§
§
§
§