Redshift:定义复合主键 [英] Redshift : defining composite primary key
本文介绍了Redshift:定义复合主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表,要为其定义一个包含redshift中两列的复合主键.我在创建表语法时遇到了一些麻烦.这是我正在尝试做的事情:
I have a table for which I want to define a composite primary key with two columns in redshift. I am having some trouble with create table syntax. Here is what I am trying to do :
Create table metrics (
id varchar(30),
runtime timestamp,
category varchar(30),
location varchar(30))
primary key(id, runtime),
sortkey(runtime);
失败,并显示一条消息:
It is failing with a message :
ERROR: syntax error at or near "PRIMARY"
任何人都可以帮助我找出解决方法吗?预先感谢.
Can anyone please help me figure out how to fix it? Thanks in advance.
推荐答案
primary key
约束位于包含列的括号内:
The primary key
constraint goes inside the parentheses containing the columns:
Create table metrics (
id varchar(30),
runtime timestamp,
category varchar(30),
location varchar(30),
primary key(id, runtime)
)
sortkey(runtime);
这篇关于Redshift:定义复合主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文