获取雪花中的主键列列表 [英] Get List of Primary Key Columns in Snowflake

本文介绍了获取雪花中的主键列列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个复合主键.在Information_Schema.Table_Constraints中,我可以看到1条该键的记录,但是在构成此主键的列上没有信息.

I have a composite primary key. In Information_Schema.Table_Constraints I can see 1 record for this key but it does not have information on columns which make this primary key.

在哪里可以找到约束列的列表?

where can i find list of columns for constraints?

推荐答案

您可以使用SHOW PRIMARY KEYS命令查找组成给定主键的列.例如:

You can use the SHOW PRIMARY KEYS command to find the columns that make up a given primary key. For example:

CREATE OR REPLACE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b));
SHOW PRIMARY KEYS IN TABLE t1;

created_on  database_name   schema_name table_name  column_name key_sequence    constraint_name comment
2020-09-24 13:48:50.208 -0700   ANDREW_DB   PUBLIC  T1  A   1   SYS_CONSTRAINT_159d987b-8160-458e-bad1-50abda169c16 
2020-09-24 13:48:50.208 -0700   ANDREW_DB   PUBLIC  T1  B   2   SYS_CONSTRAINT_159d987b-8160-458e-bad1-50abda169c16 

您还可以使用以下命令查看给定上下文(您有权访问)中所有表的主键:

You can also view primary keys for all tables in a given context (that you have access to) with these commands:

SHOW PRIMARY KEYS IN SCHEMA;
SHOW PRIMARY KEYS IN DATABASE;
SHOW PRIMARY KEYS IN ACCOUNT;

这篇关于获取雪花中的主键列列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆