Enum sqlparser::ast::TableConstraint
source · pub enum TableConstraint {
Unique {
name: Option<Located<Ident>>,
columns: Vec<Located<Ident>>,
is_primary: bool,
},
ForeignKey {
name: Option<Located<Ident>>,
columns: Vec<Located<Ident>>,
foreign_table: ObjectName,
referred_columns: Vec<Located<Ident>>,
on_delete: Option<ReferentialAction>,
on_update: Option<ReferentialAction>,
},
Check {
name: Option<Located<Ident>>,
expr: Box<Expr>,
},
Index {
display_as_key: bool,
name: Option<Located<Ident>>,
index_type: Option<IndexType>,
columns: Vec<Located<Ident>>,
},
FulltextOrSpatial {
fulltext: bool,
index_type_display: KeyOrIndexDisplay,
opt_index_name: Option<Located<Ident>>,
columns: Vec<Located<Ident>>,
},
}
Expand description
A table-level constraint, specified in a CREATE TABLE
or an
ALTER TABLE ADD <constraint>
statement.
Variants§
Unique
Fields
[ CONSTRAINT <name> ] { PRIMARY KEY | UNIQUE } (<columns>)
ForeignKey
Fields
foreign_table: ObjectName
on_delete: Option<ReferentialAction>
on_update: Option<ReferentialAction>
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>] }
).
Check
[ CONSTRAINT <name> ] CHECK (<expr>)
Index
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.
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]...
FulltextOrSpatial
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 moresource§impl Debug for TableConstraint
impl Debug for TableConstraint
source§impl<'de> Deserialize<'de> for TableConstraint
impl<'de> Deserialize<'de> for TableConstraint
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl Display for TableConstraint
impl Display for TableConstraint
source§impl Hash for TableConstraint
impl Hash for TableConstraint
source§impl Ord for TableConstraint
impl Ord for TableConstraint
source§fn cmp(&self, other: &TableConstraint) -> Ordering
fn cmp(&self, other: &TableConstraint) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<TableConstraint> for TableConstraint
impl PartialEq<TableConstraint> 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 ==
.source§impl PartialOrd<TableConstraint> for TableConstraint
impl PartialOrd<TableConstraint> for TableConstraint
source§fn partial_cmp(&self, other: &TableConstraint) -> Option<Ordering>
fn partial_cmp(&self, other: &TableConstraint) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more