pub enum TableConstraint {
Unique {
name: Option<Ident>,
columns: Vec<Ident>,
is_primary: bool,
characteristics: Option<ConstraintCharacteristics>,
},
ForeignKey {
name: Option<Ident>,
columns: Vec<Ident>,
foreign_table: ObjectName,
referred_columns: Vec<Ident>,
on_delete: Option<ReferentialAction>,
on_update: Option<ReferentialAction>,
characteristics: Option<ConstraintCharacteristics>,
},
Check {
name: Option<Ident>,
expr: Box<Expr>,
},
Index {
display_as_key: bool,
name: Option<Ident>,
index_type: Option<IndexType>,
columns: Vec<Ident>,
},
FulltextOrSpatial {
fulltext: bool,
index_type_display: KeyOrIndexDisplay,
opt_index_name: Option<Ident>,
columns: Vec<Ident>,
},
}
Expand description
A table-level constraint, specified in a CREATE TABLE
or an
ALTER TABLE ADD <constraint>
statement.
Variants§
Unique
[ CONSTRAINT <name> ] { PRIMARY KEY | UNIQUE } (<columns>)
Fields
characteristics: Option<ConstraintCharacteristics>
ForeignKey
A referential integrity constraint ([ CONSTRAINT <name> ] FOREIGN KEY (<columns>) REFERENCES <foreign_table> (<referred_columns>) { [ON DELETE <referential_action>] [ON UPDATE <referential_action>] | [ON UPDATE <referential_action>] [ON DELETE <referential_action>] }
).
Fields
foreign_table: ObjectName
on_delete: Option<ReferentialAction>
on_update: Option<ReferentialAction>
characteristics: Option<ConstraintCharacteristics>
Check
[ CONSTRAINT <name> ] CHECK (<expr>)
Index
MySQLs index definition for index creation. Not present on ANSI so, for now, the usage is restricted to MySQL, as no other dialects that support this syntax were found.
{INDEX | KEY} [index_name] [index_type] (key_part,...) [index_option]...
Fields
display_as_key: bool
Whether this index starts with KEY (true) or INDEX (false), to maintain the same syntax.
index_type: Option<IndexType>
Optional index type.
FulltextOrSpatial
MySQLs fulltext definition. Since the SPATIAL
definition is exactly the same,
and MySQL displays both the same way, it is part of this definition as well.
Supported syntax:
{FULLTEXT | SPATIAL} [INDEX | KEY] [index_name] (key_part,...)
key_part: col_name
Fields
index_type_display: KeyOrIndexDisplay
Whether the type is followed by the keyword KEY
, INDEX
, or no keyword at all.
Trait Implementations§
Source§impl Clone for TableConstraint
impl Clone for TableConstraint
Source§fn clone(&self) -> TableConstraint
fn clone(&self) -> TableConstraint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more