Dan*_*SFT 5 amazon-web-services amazon-redshift
我使用以下查询来创建我的表.
create table t1 (url varchar(250) unique);
Run Code Online (Sandbox Code Playgroud)
然后我插入大约500个网址,两次.我期待第二次我的URL中没有新条目显示在我的表中,而是我的计数值加倍:
select count(*) from t1;
Run Code Online (Sandbox Code Playgroud)
我想要的是,当我尝试添加已经在我的表中的URL时,它会被跳过.我在表格中宣称减速度不正确吗?
我正在使用AWS的RedShift.
样品
urlenrich=# insert into seed(url, source) select 'http://www.google.com', '1';
INSERT 0 1
urlenrich=# select * from seed;
url | wascrawled | source | date_crawled
-----------------------+------------+--------+--------------
http://www.google.com | 0 | 1 |
(1 row)
urlenrich=# insert into seed(url, source) select 'http://www.google.com', '1';
INSERT 0 1
urlenrich=# select * from seed;
url | wascrawled | source | date_crawled
-----------------------+------------+--------+--------------
http://www.google.com | 0 | 1 |
http://www.google.com | 0 | 1 |
(2 rows)
Run Code Online (Sandbox Code Playgroud)
输出\ d种子
urlenrich =#\ d seed
Table "public.seed"
Column | Type | Modifiers
--------------+-----------------------------+-----------
url | character varying(250) |
wascrawled | integer | default 0
source | integer | not null
date_crawled | timestamp without time zone |
Indexes:
"seed_url_key" UNIQUE, btree (url)
Run Code Online (Sandbox Code Playgroud)
Dan*_*SFT 11
找出问题所在
Amazon RedShift不强制执行约束......
如此处所述 http://docs.aws.amazon.com/redshift/latest/dg/t_Defining_constraints.html
他们说他们可能会在某些时候改变它.
新的11/21/2013 RDS增加了对PostGres的支持,如果你需要独特的,这样的postgres rds实例现在是最好的方式.
| 归档时间: |
|
| 查看次数: |
6849 次 |
| 最近记录: |