美文网首页
【pgsql】用SQL语句查某一张表的约束

【pgsql】用SQL语句查某一张表的约束

作者: calvinbj | 来源:发表于2024-03-10 09:58 被阅读0次

    【样例】查询本地pg数据库中pt_dxsl_4413020001_12298这个表的约束条件有哪些?

    SELECT
         tc.constraint_name, tc.table_name, kcu.column_name, 
         ccu.table_name AS foreign_table_name,
         ccu.column_name AS foreign_column_name,
         tc.is_deferrable,tc.initially_deferred
     FROM 
         information_schema.table_constraints AS tc 
         JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name
         JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name
     WHERE  tc.table_name = 'pt_dxsl_4413020001_12298'; 
    
    上面SQL语句的查询结果.png

    编写于 2024-03-11

    相关文章

      网友评论

          本文标题:【pgsql】用SQL语句查某一张表的约束

          本文链接:https://www.haomeiwen.com/subject/nefpzdtx.html