pub trait AlterTableBuilder {
// Required methods
fn add(self, columns: Vec<AlterColumns>) -> Altered;
fn modify(self, columns: Vec<AlterColumns>) -> Altered;
fn drop(self, column: &str) -> Altered;
fn rename_column(self, column: &str, new_name: &str) -> Altered;
fn rename(self, new_table_name: &str) -> Altered;
}Required Methods§
Sourcefn add(self, columns: Vec<AlterColumns>) -> Altered
fn add(self, columns: Vec<AlterColumns>) -> Altered
Adds a column(s) to a table.
let conn = OracleConnect::new(connection_string, username, password)?;
let column = AlterColumns {
name: String::from("title"),
data_type: CreateDataTypes::VARCHAR(10),
default: Some(String::from("PMO")),
not_null: true,
};
conn.alter()
.table("employees")
.add(vec![column])
.build()?;The same as:
ALTER TABLE employees ADD title VARCHAR2(10) DEFAULT 'PMO' NOT NULL;Sourcefn modify(self, columns: Vec<AlterColumns>) -> Altered
fn modify(self, columns: Vec<AlterColumns>) -> Altered
Modifies a column(s) on a table.
let conn = OracleConnect::new(connection_string, username, password)?;
let column = AlterColumns {
name: String::from("title"),
data_type: CreateDataTypes::VARCHAR(10),
default: Some(String::from("PMO")),
not_null: true,
};
conn.alter()
.table("employees")
.modify(vec![column])
.build()?;The same as:
ALTER TABLE employees MODIFY title VARCHAR2(10) DEFAULT 'PMO' NOT NULL;Sourcefn drop(self, column: &str) -> Altered
fn drop(self, column: &str) -> Altered
Drops a column from a table.
let conn = OracleConnect::new(connection_string, username, password)?;
conn.alter()
.table("sales")
.drop("description")
.build()?;The same as:
ALTER TABLE sales DROP COLUMN description;Sourcefn rename_column(self, column: &str, new_name: &str) -> Altered
fn rename_column(self, column: &str, new_name: &str) -> Altered
Renames a column from a table.
let conn = OracleConnect::new(connection_string, username, password)?;
conn.alter()
.table("sales")
.rename_column("salesman", "employee")
.build()?;The same as:
ALTER TABLE sales RENAME COLUMN salesman TO employee;