0

i want use this query 'ANALYZE TABLE {tableName}' but i think mybatis supports only CRUD. how to use 'ANALYZE TABLE' in mybatis?

2
  • Have you tried? It should work as a normal SELECT. Commented Feb 5, 2020 at 7:45
  • nope. because normal SELECT needs a return type. Commented Feb 7, 2020 at 0:41

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.