i want use this query 'ANALYZE TABLE {tableName}' but i think mybatis supports only CRUD. how to use 'ANALYZE TABLE' in mybatis?
1 Answer
Just declare it as a normal select and specify Map as the return type.
@Select("analyze table ${tableName}")
Map<String, Object> analyzeTable(String tableName);
@Test
public void testAnalyzeTable() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
Mapper mapper = sqlSession.getMapper(Mapper.class);
Map<String, Object> result = mapper.analyzeTable("users");
assertEquals("test.users", result.get("Table"));
assertEquals("analyze", result.get("Op"));
assertEquals("status", result.get("Msg_type"));
assertEquals("OK", result.get("Msg_text"));
}
}
Tested using...
- MariaDB 10.4.10
- MariaDB Connector/J 2.5.4