如何在JavaSpringBoot中获取postgresql列名

如何在JavaSpringBoot中获取postgresql列名,java,spring,postgresql,spring-mvc,spring-data-jpa,Java,Spring,Postgresql,Spring Mvc,Spring Data Jpa,我正在尝试获取postgresql表的列名。我尝试过使用information_模式,但在我的javamvc项目中不起作用。我该怎么办 这实际上是我关于StackOverflow的第一个问题,如果我的问题很难理解,我很抱歉。谢谢大家! public interface MyFileRepository extends JpaRepository<MyEntityModel, Long> { @Query("select column_name,data_type from i

我正在尝试获取postgresql表的列名。我尝试过使用information_模式,但在我的javamvc项目中不起作用。我该怎么办

这实际上是我关于StackOverflow的第一个问题,如果我的问题很难理解,我很抱歉。谢谢大家!

public interface MyFileRepository extends JpaRepository<MyEntityModel, Long> {
    @Query("select column_name,data_type from information_schema.columns where table_name = 'MyEntityModel';")
    List<MyEntityModel> myList();
}

关于模式。您可以通过两种方式设置默认架构:

将其放入propertiesor.yml文件spring.datasource.schema=您的模式名

将其放入实体模型@Tableschema=SCHEMA\u NAME中

关于获取有关表的信息,您可以查看以下开放式问题:


您可以查看此处的链接