How can I replicate “SHOW TABLES” in Hibernate?

前端 未结 3 608
感动是毒
感动是毒 2021-01-14 05:14

I\'m trying to iterate over all of my tables so I can truncate each one (at the beginning of each of my JBehave tests).

I thought I would be able to:



        
3条回答
  •  野的像风
    2021-01-14 06:02

    Try something like this:

    SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE();
    

    For columns (same situation with Hibernate) try:

    SELECT column_name FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME=YOUR_TABLE_NAME
    

提交回复
热议问题