pub enum TableConstraint {
PrimaryKey {
name: Option<String>,
columns: Vec<String>,
},
Unique {
name: Option<String>,
columns: Vec<String>,
nulls_not_distinct: bool,
},
Check {
name: Option<String>,
expr: Expr,
},
Index {
name: Option<String>,
columns: Vec<String>,
},
}Expand description
v7.9.18 — table-level constraint at the end of a CREATE TABLE column list. Either a composite PRIMARY KEY or a UNIQUE (single- or multi-column).
Variants§
PrimaryKey
PRIMARY KEY (col1, col2, ...). Implies NOT NULL on each
referenced column. Engine builds a BTree index named
<table>_pkey and enforces composite uniqueness on INSERT.
Unique
UNIQUE (col1, col2, ...). Engine builds a BTree index
named <table>_<leading_col>_key (single-column) or
<table>_<leading_col>_<…>_key (composite) and enforces
uniqueness on INSERT.
Fields
Check
v7.13.0 — CHECK (<expr>) table-level constraint
(mailrs round-5 G3). Column-level inline CHECKs fold into
this same variant at parse time. Engine evaluates the
predicate against each INSERT/UPDATE candidate row; a
false / NULL result rejects the mutation.
Index
v7.15.0 — MySQL KEY name (cols) / INDEX name (cols)
non-unique secondary-index declaration inline in CREATE
TABLE. Engine builds a BTree index on the leading column
(composite columns parse but only the leading column is
honoured at v7.15 — matches the existing
CreateIndexStatement::extra_columns semantics). Useful
for mysql/blog-style schemas that lean on routine
secondary indexes for ORM lookups.
Trait Implementations§
Source§impl Clone for TableConstraint
impl Clone for TableConstraint
Source§fn clone(&self) -> TableConstraint
fn clone(&self) -> TableConstraint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TableConstraint
impl Debug for TableConstraint
Source§impl Display for TableConstraint
impl Display for TableConstraint
Source§impl PartialEq for TableConstraint
impl PartialEq for TableConstraint
Source§fn eq(&self, other: &TableConstraint) -> bool
fn eq(&self, other: &TableConstraint) -> bool
self and other values to be equal, and is used by ==.