在 Vertica 数据库中为 table 查找应用了唯一约束的列名称
Find column names with unique constraints applied, for a table in Vertica database
在 Vertica 数据库中,我想知道某个 table 的列,其中应用了约束 "Unique"。
示例:
CREATE TABLE dim1 ( c1 INTEGER,
c2 INTEGER,
c3 INTEGER,
UNIQUE (c1, c2)
);
我想 运行 查询,在其中输入 table "dim1" 的名称,结果将是 "c1,c2"
有关唯一性的更多信息(link 中的最后一行)https://my.vertica.com/docs/7.0.x/HTML/Content/Authoring/AdministratorsGuide/Constraints/UniqueConstraints.htm
通过查询系统目录很容易做到这一点,特别是 V_CATALOG.CONSTRAINT_COLUMNS
:
select column_name from V_CATALOG.CONSTRAINT_COLUMNS
where table_name = 'dim1' and constraint_type = 'u'
在 Vertica 数据库中,我想知道某个 table 的列,其中应用了约束 "Unique"。
示例:
CREATE TABLE dim1 ( c1 INTEGER,
c2 INTEGER,
c3 INTEGER,
UNIQUE (c1, c2)
);
我想 运行 查询,在其中输入 table "dim1" 的名称,结果将是 "c1,c2"
有关唯一性的更多信息(link 中的最后一行)https://my.vertica.com/docs/7.0.x/HTML/Content/Authoring/AdministratorsGuide/Constraints/UniqueConstraints.htm
通过查询系统目录很容易做到这一点,特别是 V_CATALOG.CONSTRAINT_COLUMNS
:
select column_name from V_CATALOG.CONSTRAINT_COLUMNS
where table_name = 'dim1' and constraint_type = 'u'