'DESCRIBE TABLE see which columns are NOT NULL
In Apache Spark SQL (Azure Databricks), I created a table like this:
CREATE TABLE t(
a BIGINT,
b BIGINT NOT NULL
)
I have verified that I have one nullable column and one non-nullable column, as I get an error if I try to insert NULL in column b but I can insert null in column a.
However, the following statement
DESCRIBE TABLE t
does not tell me which columns are nullable and which are not null. Neither does DESCRIBE TABLE EXTENDED. How can I get the full description?
Solution 1:[1]
Use this
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_SCHEMA = "database_name"
AND
TABLE_NAME ="t"
Column name your looking for is called "IS_NULLABLE"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Anthony Dewstow |
