こちらの質問に対する Command-R+ の一次回答です。
生成AI で PostgreSQL の SQL を作成
SELECT
    b.table_name AS table_b_name,
    a.column_name IS NOT DISTINCT FROM b.column_name AS column_match,
    a.is_nullable = FALSE AND b.is_nullable = TRUE AS not_null_mismatch
FROM information_schema.columns a
JOIN information_schema.columns b ON a.column_name = b.column_name
    AND a.table_name = 'table_a'
    AND b.table_name <> 'table_a'
    AND b.table_schema = 'your_schema_name'
WHERE a.table_schema = 'your_schema_name'
AND a.column_name = b.column_name
AND a.is_nullable = FALSE
AND (b.is_nullable = TRUE OR b.column_default IS NOT NULL)
GROUP BY b.table_name, a.column_name, a.is_nullable, b.is_nullable, b.column_default;
実行結果
ERROR:  operator does not exist: information_schema.yes_or_no = boolean
行 4:     a.is_nullable = FALSE AND b.is_nullable = TRUE AS not_nu...
                        ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.