zoukankan      html  css  js  c++  java
  • oracle 查询所有约束

    主键约束
    SELECT
      USER_CONS_COLUMNS.CONSTRAINT_NAME AS 约束名,
      USER_CONS_COLUMNS.TABLE_NAME AS 表名,
      USER_CONS_COLUMNS.COLUMN_NAME AS 列名,
      USER_CONS_COLUMNS.POSITION AS 位置
    FROM
      USER_CONSTRAINTS
        JOIN USER_CONS_COLUMNS
        ON (USER_CONSTRAINTS.CONSTRAINT_NAME
    = USER_CONS_COLUMNS.CONSTRAINT_NAME)
    WHERE
      CONSTRAINT_TYPE = 'P';

    外键约束
    SELECT
      USER_CONS_COLUMNS.CONSTRAINT_NAME AS 约束名,
      USER_CONS_COLUMNS.TABLE_NAME AS 子表名,
      USER_CONS_COLUMNS.COLUMN_NAME AS 子表列名,
      USER_CONS_COLUMNS.POSITION AS 位置,
      USER_INDEXES.TABLE_NAME AS 主表名,
      USER_IND_COLUMNS.COLUMN_NAME AS 主表列名
    FROM
      USER_CONSTRAINTS
        JOIN USER_CONS_COLUMNS
        ON (USER_CONSTRAINTS.CONSTRAINT_NAME
            = USER_CONS_COLUMNS.CONSTRAINT_NAME)
        JOIN USER_INDEXES
        ON (USER_CONSTRAINTS.R_CONSTRAINT_NAME
            = USER_INDEXES.INDEX_NAME)
        JOIN USER_IND_COLUMNS
        ON (USER_INDEXES.INDEX_NAME = USER_IND_COLUMNS.INDEX_NAME)
    WHERE
      CONSTRAINT_TYPE = 'R';

    其他约束
    SELECT
      USER_CONS_COLUMNS.CONSTRAINT_NAME AS 约束名,
      USER_CONS_COLUMNS.TABLE_NAME AS 表名,
      USER_CONS_COLUMNS.COLUMN_NAME AS 列名,
      USER_CONS_COLUMNS.POSITION AS 位置,
      CONSTRAINT_TYPE,
      SEARCH_CONDITION
    FROM
      USER_CONSTRAINTS
        JOIN USER_CONS_COLUMNS
        ON (USER_CONSTRAINTS.CONSTRAINT_NAME
            = USER_CONS_COLUMNS.CONSTRAINT_NAME)
    WHERE
      CONSTRAINT_TYPE IN ('C', 'V', 'O');

  • 相关阅读:
    The Tamworth Two chapter 2.4
    USACO Controlling Companies chapter 2.3 已跪
    非递归快排
    链表二路归并
    Money Systems chapter 2.3 dp
    #pragma pack与sizeof union
    快慢指针
    12
    11
    10
  • 原文地址:https://www.cnblogs.com/zheng-hong-bo/p/4269496.html
Copyright © 2011-2022 走看看