SELECT *
FROM information_schema.columns 
WHERE table_name='act_hi_attachment' 
AND table_schema='public';



SELECT null AS object_id,table_name AS tb_name,column_name AS name,data_type,null AS column_id,COALESCE(col_description (c.oid, col.ordinal_position),column_name) AS title,
        CASE
        WHEN is_nullable = 'YES' THEN '0'
                ELSE
                        '1'
                END AS is_required, 
        CASE    
                WHEN LENGTH ( B.attname ) > 0 THEN
                1 ELSE 0 
                END AS is_primary,
        CASE
        WHEN is_identity = 'NO' THEN '0'
    ELSE
        '1'
    END AS  is_identity,
        character_maximum_length AS max_length,numeric_precision AS col_length,numeric_precision_radix AS col_decimal,column_default AS default_text 
FROM information_schema.columns AS col
LEFT JOIN pg_namespace ns ON ns.nspname = col.table_schema
LEFT JOIN pg_class c ON col.table_name = c.relname
LEFT JOIN (
    SELECT
        pg_attribute.attname,
        pg_class 
    FROM
        pg_index,
        pg_class,
        pg_attribute 
    WHERE
        pg_class.oid = 'act_hi_attachment' :: regclass 
        AND pg_index.indrelid = pg_class.oid 
        AND pg_attribute.attrelid = pg_class.oid 
        AND pg_attribute.attnum = ANY ( pg_index.indkey ) 
    ) b ON col.COLUMN_NAME = b.attname 
WHERE table_name in ('act_hi_attachment')
AND table_schema='public';

文档更新时间: 2023-06-17 11:55   作者:admin