本文整理汇总了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
}