I'm trying to extract the database metadata of JDBC database driver.
And now I am facing a part of the documentation that I can not explain to myself:
The Method DatabaseMetaData.getColumns(...);
(JavaDoc) states two different "nullability" columns:
NULLABLE int => is NULL allowed. columnNoNulls - might not allow NULL values columnNullable - definitely allows NULL values columnNullableUnknown - nullability unknown
and
IS_NULLABLE String => ISO rules are used to determine the nullability for a column. YES --- if the column can include NULLs NO --- if the column cannot include NULLs empty string --- if the nullability for the column is unknown
The only idea i could think of for the two different columns is:
That one defines the table column could be null when read and the other states that into this table column could null be inserted. But I was not able to determine the correctness of this idea.
Does anyone know for sure what is the difference between these two columns? Is there somewhere a more detailed information about this part of JDBC API?
Thanks for helping.
As far as I am aware the meaning is the same, however IS_NULLABLE
follows the information_schema.columns
view definition from SQL:2011 Schemata (ISO-9075-11:2011), although SQL:2011 doesn't specify the empty string meaning (it only specifies NO
if not nullable and YES
for all other cases). The column NULLABLE
uses the value of the constants columnNoNulls
, columnNullable
and columnNullableUnknown
which might be used for more readable code, and for use in a switch
(which pre-Java 7 didn't support string). It is also equivalent to the return value of ResultSetMetaData.isNullable(int)
.
In general the definition of the metadata result sets are based on the information_schema
tables and views defined in ISO-9075-11:2011 (SQL:2011 Schemata) or other versions of the SQL standard. This specification can be used for more information regarding the columns, with the exception of JDBC specific additions. These additions are usually not explicitly specified except for what is in the javadoc (and by reading between the lines in other parts of the apidoc and specification), although those additions generally follow the rules and logic of the SQL standard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With