我使用以下查询来创建我的表。
create table t1 (url varchar(250) unique);
然后我插入大约 500 个网址,两次。我希望第二次获得没有新条目出现在我的表中的 URL,而是我的计数值加倍:
select count(*) from t1;
我想要的是,当我尝试添加一个已经在我的表中的 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)
\d 种子的输出
urlenrich=# \d 种子
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)