sql:=`SELECT DISTINCT C.REFERENCED_TABLE_SCHEMA,C.REFERENCED_TABLE_NAME,C.TABLE_SCHEMA,C.TABLE_NAME,C.CONSTRAINT_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE C JOIN INFORMATION_SCHEMA. TABLES T ON T.TABLE_NAME = C.TABLE_NAME WHERE C.REFERENCED_TABLE_NAME IS NOT NULL`
sql:=`SELECT DISTINCT C.REFERENCED_TABLE_SCHEMA,C.REFERENCED_TABLE_NAME,C.TABLE_SCHEMA,C.TABLE_NAME,C.CONSTRAINT_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE C JOIN INFORMATION_SCHEMA. TABLES T ON T.TABLE_NAME = C.TABLE_NAME WHERE C.REFERENCED_TABLE_NAME IS NOT NULL`
sql=sql+fmt.Sprintf(` AND C.TABLE_SCHEMA = "%s"`,StringEscape(dbName))
sql=sql+fmt.Sprintf(` AND C.TABLE_SCHEMA = "%s"`,StringEscape(dbName))
vartables[]string
for_,tb:=rangetbName{
tables=append(tables,"'"+StringEscape(tb)+"'")
}
iflen(tbName)>0{
iflen(tbName)>0{
extra:=fmt.Sprintf(` AND C.TABLE_NAME IN ("%s")`,StringEscape(strings.Join(tbName,`","`)))
extra:=fmt.Sprintf(` AND C.TABLE_NAME IN ("%s")`,strings.Join(tables,","))