PostgreSQL:多次指定列 "crab_id"
PostgreSQL: Column "crab_id" Specified More than Once
使用 PostgreSQL 调用,
CREATE TABLE condor_xrootd AS
SELECT * FROM condor INNER JOIN xrootd_ext
ON (
xrootd_ext.CRAB_Id = condor.CRAB_Id AND
REPLACE(condor.CRAB_ReqName, '_', ':') = xrootd_ext.CRAB_ReqName
);
我收到错误,
$ psql condor -f ./sql/inner_join.sql
psql:./sql/inner_join.sql:6: ERROR: column "crab_id" specified more than once
这是可以理解的,因为每个 table 都有一个 Crab_Id 列。我希望能够在不指定列的情况下进行内部联接,因为我在两个 table 中合并了大约 400 列。
请告诉我是否可以在不单独列出列的情况下以某种方式消除此错误。
编辑:
我忘了提到速度 和稳定性 在这里至关重要,因为我的加入可能需要几天时间。
create table condor_xrootd as
select *
from
condor
inner join
xrootd_ext using (crab_id)
where replace(condor.crab_reqname, '_', ':') = xrootd_ext.crab_reqname
您从由两个 table 构建的结果集中创建 table。您的错误表明列 crab_id
存在于 condor
和 xrootd_ext
table 中,而 Postgresql 不知道应该选择哪个。
您应该指定要创建的字段 table。像这样:
CREATE TABLE condor_xrootd AS
SELECT
condor.*, -- here we take all fields from condor table
xrootd_ext.crab_reqName -- here we take crab_reqName field from xrootd_ext
FROM condor INNER JOIN xrootd_ext
ON (
xrootd_ext.CRAB_Id = condor.CRAB_Id AND
REPLACE(condor.CRAB_ReqName, '_', ':') = xrootd_ext.CRAB_ReqName
);
使用 PostgreSQL 调用,
CREATE TABLE condor_xrootd AS
SELECT * FROM condor INNER JOIN xrootd_ext
ON (
xrootd_ext.CRAB_Id = condor.CRAB_Id AND
REPLACE(condor.CRAB_ReqName, '_', ':') = xrootd_ext.CRAB_ReqName
);
我收到错误,
$ psql condor -f ./sql/inner_join.sql
psql:./sql/inner_join.sql:6: ERROR: column "crab_id" specified more than once
这是可以理解的,因为每个 table 都有一个 Crab_Id 列。我希望能够在不指定列的情况下进行内部联接,因为我在两个 table 中合并了大约 400 列。
请告诉我是否可以在不单独列出列的情况下以某种方式消除此错误。
编辑:
我忘了提到速度 和稳定性 在这里至关重要,因为我的加入可能需要几天时间。
create table condor_xrootd as
select *
from
condor
inner join
xrootd_ext using (crab_id)
where replace(condor.crab_reqname, '_', ':') = xrootd_ext.crab_reqname
您从由两个 table 构建的结果集中创建 table。您的错误表明列 crab_id
存在于 condor
和 xrootd_ext
table 中,而 Postgresql 不知道应该选择哪个。
您应该指定要创建的字段 table。像这样:
CREATE TABLE condor_xrootd AS
SELECT
condor.*, -- here we take all fields from condor table
xrootd_ext.crab_reqName -- here we take crab_reqName field from xrootd_ext
FROM condor INNER JOIN xrootd_ext
ON (
xrootd_ext.CRAB_Id = condor.CRAB_Id AND
REPLACE(condor.CRAB_ReqName, '_', ':') = xrootd_ext.CRAB_ReqName
);