{"record":{"id":"cf51828542ff465d","repo":"MyCATApache/Mycat-Server","slug":"can-t-find-table-define-in-schema-tablename-sche","errorCode":null,"errorMessage":"can't find table define in schema {tableName} schema:{schemaName}","messagePattern":"can't find table define in schema (.+?) schema:(.+?)","errorType":"exception","errorClass":"SQLNonTransientException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/util/RouterUtil.java","lineNumber":1375,"sourceCode":"\r\n\r\n\t/**\r\n\t *\r\n\t * 单表路由\r\n\t */\r\n\tpublic static RouteResultset tryRouteForOneTable(SchemaConfig schema, DruidShardingParseInfo ctx,\r\n\t\t\tRouteCalculateUnit routeUnit, String tableName, RouteResultset rrs, boolean isSelect,\r\n\t\t\tLayerCachePool cachePool) throws SQLNonTransientException {\r\n\r\n\t\tif (isNoSharding(schema, tableName)) {\r\n\t\t\treturn routeToSingleNode(rrs, schema.getDataNode(), ctx.getSql());\r\n\t\t}\r\n\r\n\t\tTableConfig tc = schema.getTables().get(tableName);\r\n\t\tif(tc == null) {\r\n\t\t\tString msg = \"can't find table define in schema \" + tableName + \" schema:\" + schema.getName();\r\n\t\t\tLOGGER.warn(msg);\r\n\t\t\tthrow new SQLNonTransientException(msg);\r\n\t\t}\r\n\r\n\t\tMap<String, Map<String, Set<ColumnRoutePair>>> tablesAndConditions = routeUnit.getTablesAndConditions();\r\n        if(tc.isDistTable()){\r\n            Set<String> keySet = tablesAndConditions.keySet();\r\n            //Map.Entry<String, Map<String, Set<ColumnRoutePair>>> entry = (Entry<String, Map<String, Set<ColumnRoutePair>>>) tablesAndConditions.get(keySet.toArray()[0]);\r\n            return routeToDistTableNode(schema,rrs,ctx.getSql(), tablesAndConditions, cachePool,isSelect, null);\r\n        }\r\n\r\n\t\tif(tc.isGlobalTable()) {//全局表\r\n\t\t\tif(isSelect) {\r\n\t\t\t\t// global select ,not cache route result\r\n\t\t\t\trrs.setCacheAble(false);\r\n\t\t\t\treturn routeToSingleNode(rrs, getAliveRandomDataNode(tc)/*getRandomDataNode(tc)*/, ctx.getSql());\r\n\t\t\t} else {//insert into 全局表的记录\r\n\t\t\t\treturn routeToMultiNode(false, rrs, tc.getDataNodes(), ctx.getSql(),true);\r\n\t\t\t}\r\n\t\t} else {//单表或者分库表\r","sourceCodeStart":1357,"sourceCodeEnd":1393,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/util/RouterUtil.java#L1357-L1393","documentation":"Thrown during route calculation when the table name extracted from the SQL (routeUnit) is not present in the schema's configured tables (schema.getTables()). Mycat can only route tables declared in schema.xml.","triggerScenarios":"Executing SQL that references a table not declared in schema.xml (or with a case mismatch after uppercasing); the logical schema in the connection does not contain the table definition.","commonSituations":"Table missing from schema.xml <table> entries; case-sensitivity mismatch (Mycat upper-cases table names); connecting to a schema in which the table wasn't configured; typo in table name.","solutions":["Add the table to schema.xml as a <table> entry with correct dataNode/rule, then reload config","Check table-name case: ensure the SQL name matches the schema.xml entry (Mycat matches via upper-cased names)","Verify the client connected to the correct Mycat logical schema (use fully qualified db.table or SET_SCHEMA)","If the table is intentionally unsharded, ensure it's still declared with a dataNode"],"exampleFix":"// before (schema.xml missing table)\n<schema name=\"TESTDB\">\n  <table name=\"orders\" dataNode=\"dn1,dn2\" rule=\"mod-rule\"/>\n</schema>\n// after (declare the missing table)\n<schema name=\"TESTDB\">\n  <table name=\"orders\" dataNode=\"dn1,dn2\" rule=\"mod-rule\"/>\n  <table name=\"order_item\" dataNode=\"dn1,dn2\" rule=\"mod-rule\"/>\n</schema>","handlingStrategy":"validation","validationCode":"boolean exists = schema.getTables().containsKey(tableName.trim().toUpperCase());\nif (!exists) throw new IllegalArgumentException(\"table not in schema.xml: \" + tableName);","typeGuard":null,"tryCatchPattern":"try { rrs = route(...); } catch (SQLNonTransientException e) { if (e.getMessage().startsWith(\"can't find table define\")) { LOG.warn(\"declare table in schema.xml: \" + e.getMessage()); } throw e; }","preventionTips":["Keep schema.xml table declarations in sync with application DDL","Use consistent uppercase naming for logical tables","Validate schema.xml with a startup smoke test that routes one query per table"],"tags":["config","routing","mycat"],"backgroundTag":"entity-not-found","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}