简体   繁体   English

使用Spring-Java测试Oracle DB表结构

[英]Testing Oracle DB table structure with Spring-Java

Im connecting to an external database wich im not able to populate with testdata to do a proper integration test suite for my DAO on. 我正在连接到外部数据库,但无法用testdata填充以为我的DAO做适当的集成测试套件。 As an alternative I would like to test the structure of the tables. 作为替代,我想测试表的结构。 For example that the tables im using has columns with certain names and types. 例如,im正在使用的表具有具有某些名称和类型的列。 How is this possible with Java/Spring? Java / Spring怎么可能?

In Oracle SQL Developer I can use desc <tableName>; 在Oracle SQL Developer中,我可以使用desc <tableName>; to get what I want, is there someting smilar i can do from Spring? 要获得我想要的东西,我在Spring可以做些微笑吗?

您可以使用DatabaseMetaData ,请参见此处以获取一些启发(以及此处的测试用例)

You can also use dbms_metadata package(unless you're on XE release). 您也可以使用dbms_metadata软件包(除非您使用的是XE版本)。 This will either return DDL for a database object either as SQL script or as XML formatted string. 这将以SQL脚本或XML格式的字符串返回数据库对象的DDL。

It's a way how SQLDeveloper reverse engineers object definitions. 这是SQLDeveloper反向工程对象定义的一种方式。 AFAIK you have to use database dependent approach for this. AFAIK,您必须使用数据库相关的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM