Aravind
Aravind

Reputation: 2198

How to Get non nullable Columns of a Table using java?

I am trying to get the non-nullable columns of a table through a java code.... Can anyone help me?

Upvotes: 0

Views: 523

Answers (2)

Harrison
Harrison

Reputation: 9090

not a Java answer, but you can query for it!

select 
     table_name, 
     columns_name, 
     data_type, 
     nullable 
  from ALL_TAB_COLUMNS

supply the table_name and filter on nullable

Upvotes: 1

Jesper
Jesper

Reputation: 206876

It is not completely clear what you are asking. Do you want to find out, from your Java program, which columns of a specific table are not nullable?

You can call java.sql.DatabaseMetaData.getColumns() to get information about the columns of a table. One of the items that you'll get back is IS_NULLABLE, which indicates if the column is nullable. See the API documentation of the getColumns method for detailed information.

Upvotes: 2

Related Questions