Struct sea_query::index::IndexCreateStatement [−][src]
pub struct IndexCreateStatement { /* fields omitted */ }Expand description
Create an index for an existing table
Examples
use sea_query::{*, tests_cfg::*}; let index = Index::create() .name("idx-glyph-aspect") .table(Glyph::Table) .col(Glyph::Aspect) .to_owned(); assert_eq!( index.to_string(MysqlQueryBuilder), r#"CREATE INDEX `idx-glyph-aspect` ON `glyph` (`aspect`)"# ); assert_eq!( index.to_string(PostgresQueryBuilder), r#"CREATE INDEX "idx-glyph-aspect" ON "glyph" ("aspect")"# ); assert_eq!( index.to_string(SqliteQueryBuilder), r#"CREATE INDEX `idx-glyph-aspect` ON `glyph` (`aspect`)"# );
Index with prefix
use sea_query::{*, tests_cfg::*}; let index = Index::create() .name("idx-glyph-aspect") .table(Glyph::Table) .col((Glyph::Aspect, 128)) .to_owned(); assert_eq!( index.to_string(MysqlQueryBuilder), r#"CREATE INDEX `idx-glyph-aspect` ON `glyph` (`aspect` (128))"# ); assert_eq!( index.to_string(PostgresQueryBuilder), r#"CREATE INDEX "idx-glyph-aspect" ON "glyph" ("aspect" (128))"# ); assert_eq!( index.to_string(SqliteQueryBuilder), r#"CREATE INDEX `idx-glyph-aspect` ON `glyph` (`aspect`)"# );
Index with order
use sea_query::{*, tests_cfg::*}; let index = Index::create() .name("idx-glyph-aspect") .table(Glyph::Table) .col((Glyph::Aspect, IndexOrder::Desc)) .to_owned(); assert_eq!( index.to_string(MysqlQueryBuilder), r#"CREATE INDEX `idx-glyph-aspect` ON `glyph` (`aspect` DESC)"# ); assert_eq!( index.to_string(PostgresQueryBuilder), r#"CREATE INDEX "idx-glyph-aspect" ON "glyph" ("aspect" DESC)"# ); assert_eq!( index.to_string(SqliteQueryBuilder), r#"CREATE INDEX `idx-glyph-aspect` ON `glyph` (`aspect` DESC)"# );
Index with prefix and order
use sea_query::{*, tests_cfg::*}; let index = Index::create() .name("idx-glyph-aspect") .table(Glyph::Table) .col((Glyph::Aspect, 64, IndexOrder::Asc)) .to_owned(); assert_eq!( index.to_string(MysqlQueryBuilder), r#"CREATE INDEX `idx-glyph-aspect` ON `glyph` (`aspect` (64) ASC)"# ); assert_eq!( index.to_string(PostgresQueryBuilder), r#"CREATE INDEX "idx-glyph-aspect" ON "glyph" ("aspect" (64) ASC)"# ); assert_eq!( index.to_string(SqliteQueryBuilder), r#"CREATE INDEX `idx-glyph-aspect` ON `glyph` (`aspect` ASC)"# );
Implementations
Construct a new IndexCreateStatement
Add index column
Set index as full text.
On MySQL, this is FULLTEXT.
On PgSQL, this is GIN.
Set index type. Not available on Sqlite.
Trait Implementations
Build corresponding SQL statement for certain database backend and return SQL string
Build corresponding SQL statement for certain database backend and return SQL string
Build corresponding SQL statement for certain database backend and return SQL string
Auto Trait Implementations
impl !RefUnwindSafe for IndexCreateStatementimpl !Send for IndexCreateStatementimpl !Sync for IndexCreateStatementimpl Unpin for IndexCreateStatementimpl !UnwindSafe for IndexCreateStatementBlanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = TShould always be Self
pub fn vzip(self) -> V