Skip to main content

I would like to add NULL/NOT NULL to the SQL export not to the ER Diagram. But I don't know how. Thanks.

Hi Looloo


Thanks for your post. Lucidchart exports the content of your diagram so you can add NULL/NOT NULL to your generated SQL statement after you export. Please let us know if you have any questions on this.


Do you plan to add in functionality to allow the setting of NULL/!NULL ? 


Hi Alek

Thanks for your post! Adding this feature isn't currently on our short-term roadmap. If you'd like to potentially see this functionality added in the future please submit to the product feedback section of the community. Our team uses this form to combine like requests from users and present them to our Product team. 


Feature officially requested. Looking forward to seeing this implemented. Would be super helpful. Thanks!


As workaround you can change query and manually add NOT_NULL to the data_type using concat function

for postgresql:


SET enable_nestloop = 0;
SELECT 'postgresql' AS dbms
t.table_catalog
t.table_schema
t.table_name
c.column_name
c.ordinal_position
concat(c.data_type ' ' replace(replace(k3.is_nullable 'YES' '') 'NO' 'NOT_NULL')) as "c.data_type"
c.character_maximum_length
n.constraint_type
k2.table_schema
k2.table_name
k2.column_name
FROM information_schema.tables t
NATURAL LEFT JOIN information_schema.columns c
LEFT JOIN(information_schema.key_column_usage k NATURAL JOIN information_schema.table_constraints n NATURAL LEFT JOIN information_schema.referential_constraints r)
ON c.table_catalog = k.table_catalog AND c.table_schema = k.table_schema AND
c.table_name = k.table_name AND c.column_name = k.column_name
LEFT JOIN information_schema.key_column_usage k2 ON k.position_in_unique_constraint = k2.ordinal_position AND
r.unique_constraint_catalog = k2.constraint_catalog AND
r.unique_constraint_schema = k2.constraint_schema AND
r.unique_constraint_name = k2.constraint_name
INNER JOIN information_schema.columns k3 ON k3.column_name = c.column_name AND
k3.table_name = c.table_name
WHERE t.TABLE_TYPE = 'BASE TABLE'
AND t.table_schema NOT IN ('information_schema' 'pg_catalog');

 


Thanks for sharing that workaround Valentyn! 


Reply