如何选择表中除一个以外的所有列 [英] How to Select all columns of a table except one

查看:72
本文介绍了如何选择表中除一个以外的所有列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下:

 CREATE TABLE tableC AS
 (SELECT tableA.*,
  ST_Intersection (B.geom, A.geom) as geom2  -- generate geom
 FROM tableB, tableA
 JOIN tableB
 ON ST_Intersects (A.geom, b.geom)
 WHERE test.id = 2);

现在正在工作,但是我有两列geom和geom2!
内部几何列中,我将基于交点获得新的几何形状。那么,如何选择除geom列之外的tableA?

Now It is working but I have two columns geom and geom2! Inside geom column I will have the new geometry based on the intersection. So how can I select tableA except the geom column?

推荐答案

创建具有所有列的表,然后删除 geom 列并重命名新的:

Create the table with all the columns and after that drop the geom column and rename the new one:

CREATE TABLE tableC AS
SELECT
    tableA.*,
    ST_Intersection (B.geom, A.geom) as geom2  -- generate geom
FROM
    tableA inner JOIN tableB ON ST_Intersects (A.geom, b.geom)
WHERE test.id = 2
;

alter table tableC drop column geom;
alter table tableC rename column geom2 to geom;

这篇关于如何选择表中除一个以外的所有列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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