which database product are you using? In Oracle 8 you can query certain Oracle tables to find the information Example: use the query "SELECT constraint_name, contraint_type, deferrable, validated FROM dba_constraints WHERE owner = "Scott" AND table_name = 'Employees'" the owner statement in the where clause is optional(only needed if the table exists twice in the same database!). You also have to have permissions to these table to access the data. Jamie
Joined: Jun 13, 2001
thanks, jlrober! I am using SQL Server now, but wish my code would work for ORACLE too ( if possible ). So I do not want to use DB's system objects, and want to use jdbc's features. I am wondering if DatabaseMetaData has this info. How to use it to get constraint's info? -Zhining Zhang
Joined: Jun 25, 2001
You probably have already looked into the following DatabaseMetaData methods, but in case you overlooked them: getExportedKeys(String catalog, String schema, String table) getImportedKeys(String catalog, String schema, String table) getPrimaryKeys(String catalog, String schema, String table) The above are only for primary key/foreign key constraints. I haven't come accross a solution for non-key constraints. jamie
"ZhiningZhang", "jlrober", The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements. Thanks.