本文整理匯總了Golang中github.com/youtube/vitess/go/vt/schema.Table.AddColumn方法的典型用法代碼示例。如果您正苦於以下問題:Golang Table.AddColumn方法的具體用法?Golang Table.AddColumn怎麽用?Golang Table.AddColumn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/youtube/vitess/go/vt/schema.Table
的用法示例。
在下文中一共展示了Table.AddColumn方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getTestSchema
// getSchema returns a fake schema object that can be given to SplitParams
func getTestSchema() map[string]*schema.Table {
table := schema.Table{
Name: "test_table",
}
zero, _ := sqltypes.BuildValue(0)
table.AddColumn("id", sqltypes.Int64, zero, "")
table.AddColumn("int32_col", sqltypes.Int32, zero, "")
table.AddColumn("uint32_col", sqltypes.Uint32, zero, "")
table.AddColumn("int64_col", sqltypes.Int64, zero, "")
table.AddColumn("uint64_col", sqltypes.Uint64, zero, "")
table.AddColumn("float32_col", sqltypes.Float32, zero, "")
table.AddColumn("float64_col", sqltypes.Float64, zero, "")
table.AddColumn("user_id", sqltypes.Int64, zero, "")
table.AddColumn("user_id2", sqltypes.Int64, zero, "")
table.AddColumn("id2", sqltypes.Int64, zero, "")
table.AddColumn("count", sqltypes.Int64, zero, "")
table.PKColumns = []int{0, 7}
addIndexToTable(&table, "PRIMARY", "id", "user_id")
addIndexToTable(&table, "idx_id2", "id2")
addIndexToTable(&table, "idx_int64_col", "int64_col")
addIndexToTable(&table, "idx_uint64_col", "uint64_col")
addIndexToTable(&table, "idx_float64_col", "float64_col")
addIndexToTable(&table, "idx_id_user_id", "id", "user_id")
addIndexToTable(&table, "idx_id_user_id_user_id_2", "id", "user_id", "user_id2")
table.SetMysqlStats(
int64Value(1000), /* TableRows */
int64Value(100), /* DataLength */
int64Value(123), /* IndexLength */
int64Value(456), /* DataFree */
)
result := make(map[string]*schema.Table)
result["test_table"] = &table
tableNoPK := schema.Table{
Name: "test_table_no_pk",
}
tableNoPK.AddColumn("id", sqltypes.Int64, zero, "")
tableNoPK.PKColumns = []int{}
result["test_table_no_pk"] = &tableNoPK
return result
}
示例2: GetSchema
// GetSchema returns a fake schema object that can be given to SplitParams
func GetSchema() map[string]*schema.Table {
table := schema.Table{
Name: "test_table",
}
zero, _ := sqltypes.BuildValue(0)
table.AddColumn("id", sqltypes.Int64, zero, "")
table.AddColumn("int32_col", sqltypes.Int32, zero, "")
table.AddColumn("uint32_col", sqltypes.Uint32, zero, "")
table.AddColumn("int64_col", sqltypes.Int64, zero, "")
table.AddColumn("uint64_col", sqltypes.Uint64, zero, "")
table.AddColumn("float32_col", sqltypes.Float32, zero, "")
table.AddColumn("float64_col", sqltypes.Float64, zero, "")
table.AddColumn("user_id", sqltypes.Int64, zero, "")
table.AddColumn("user_id2", sqltypes.Int64, zero, "")
table.AddColumn("id2", sqltypes.Int64, zero, "")
table.AddColumn("count", sqltypes.Int64, zero, "")
table.PKColumns = []int{0, 7}
addIndexToTable(&table, "PRIMARY", "id", "user_id")
addIndexToTable(&table, "idx_id2", "id2")
addIndexToTable(&table, "idx_int64_col", "int64_col")
addIndexToTable(&table, "idx_uint64_col", "uint64_col")
addIndexToTable(&table, "idx_float64_col", "float64_col")
addIndexToTable(&table, "idx_id_user_id", "id", "user_id")
addIndexToTable(&table, "idx_id_user_id_user_id_2", "id", "user_id", "user_id2")
result := make(map[string]*schema.Table)
result["test_table"] = &table
tableNoPK := schema.Table{
Name: "test_table_no_pk",
}
tableNoPK.AddColumn("id", sqltypes.Int64, zero, "")
tableNoPK.PKColumns = []int{}
result["test_table_no_pk"] = &tableNoPK
return result
}