I would like to add NULL/NOT NULL to the SQL export not to the ER Diagram. But I don't know how. Thanks.
ER Diagram-How to add NULL/NOT NULL to the DDL?
Best answer by Valentyn B
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');
Reply
Create an account in the community
A Lucid account is required to interact with the Community, and your participation is subject to the Supplemental Lucid Community Terms. You may not participate in the Community if you are under age 18. You will be redirected to the Lucid app to create an account.
Log in to the community
A Lucid account is required to interact with the Community, and your participation is subject to the Supplemental Lucid Community Terms. You may not participate in the Community if you are under age 18. You will be redirected to the Lucid app to log in.
Log in with Lucid
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.