Documentation ¶
Index ¶
- Variables
- func BuildSelectSQL(table string, columns []string, conditions string) (string, error)
- func NullFloat(buf []byte) float64
- func NullInt(buf []byte) int64
- func NullString(buf []byte) string
- func TestMySQLConnect(host, port, user, passwd, database string) error
- type Connect
- func (db *Connect) Close() error
- func (db *Connect) Explain(sql string) (exp *ExplainInfo, err error)
- func (db *Connect) GetColumns(database, table string) ([]string, error)
- func (db *Connect) Query(sql string, params ...interface{}) (QueryResult, error)
- func (db *Connect) ShowDatabases() ([]string, error)
- func (db *Connect) ShowTables(database string) ([]string, error)
- func (db *Connect) TableConstraints(d, table string) (map[string][]string, error)
- func (db *Connect) TableSize(database, table string) (int, error)
- func (db *Connect) TablesHasPrimaryKey(database string, tables []string) (bool, error)
- type ExplainInfo
- type ExplainRow
- type ExplainWarning
- type QueryResult
Constants ¶
This section is empty.
Variables ¶
View Source
var ExplainScalability = map[string]string{
"NULL": "NULL",
"ALL": "O(n)",
"index": "O(n)",
"range": "O(log n)+",
"index_subquery": "O(log n)+",
"unique_subquery": "O(log n)+",
"index_merge": "O(log n)+",
"ref_or_null": "O(log n)+",
"fulltext": "O(log n)+",
"ref": "O(log n)",
"eq_ref": "O(log n)",
"const": "O(1)",
"system": "O(1)",
}
ExplainScalability ACCESS TYPE对应的运算复杂度 [AccessType]scalability map
Functions ¶
func BuildSelectSQL ¶
func TestMySQLConnect ¶
Types ¶
type Connect ¶
type Connect struct { Addr string User string Pass string Database string Charset string Conn *sql.DB }
func NewMysqlConnect ¶
func (*Connect) Explain ¶
func (db *Connect) Explain(sql string) (exp *ExplainInfo, err error)
Explain 获取 SQL 的 explain 信息
func (*Connect) GetColumns ¶
GetColumns 查询表列
func (*Connect) Query ¶
func (db *Connect) Query(sql string, params ...interface{}) (QueryResult, error)
Query 执行SQL
func (*Connect) ShowDatabases ¶
ShowDatabases 查询库列表
func (*Connect) ShowTables ¶
ShowTables 查询表列表
func (*Connect) TableConstraints ¶
TableConstraints 查询表包含哪些约束
type ExplainInfo ¶
type ExplainInfo struct { SQL string ExplainRows []ExplainRow Warnings []ExplainWarning }
ExplainInfo 用于存放Explain信息
type ExplainRow ¶
type ExplainRow struct { ID int SelectType string TableName string Partitions string // explain partitions AccessType string PossibleKeys []string Key string KeyLen string // 索引长度,如果发生了index_merge, KeyLen 格式为 N,N,所以不能定义为整型 Ref []string Rows int64 Filtered float64 // 5.6 JSON, 5.7+, 5.5 EXTENDED Scalability string // O(1), O(n), O(log n), O(log n)+ Extra string }
ExplainRow 单行Explain
type ExplainWarning ¶
ExplainWarning explain extended 后 SHOW WARNINGS 输出的结果
Click to show internal directories.
Click to hide internal directories.