Skip to main content

I want to add a constraint like NOT NULL or AUTO_INCREMENT.  I don’t see a way to do this and I searched previous post and it seems like this might have been planned but not a feature.  If I have to add these constraints after I export that’s fine but it no longer makes LucidChart my source of truth which is why I figured there must be some way to add it. 

Good morning,
Thank you for posting your question. I don’t personally have the answer, but I am checking internally with an expert that will. I will circle back shortly. 


Hi @rifath

Thanks for your post! Currently we do not have a feature to add these constraints in an ERD. However, 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.

If you’re willing to share, we’d love to hear more details about your use case or what you’d like to see in this experience within this thread. I’ve also converted this post to an idea so that it’s visible to others within the Product Feedback section of the community - from here, they can upvote it and add details of their own.

For more information on how Lucid manages feedback via this community, take a look at this post:

As a 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_nameFROM 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_nameWHERE t.TABLE_TYPE = 'BASE TABLE'  AND t.table_schema NOT IN ('information_schema' 'pg_catalog');