如何从选择查询创建表?

时间:2015-08-25 13:07:25

标签: sql postgresql create-table

我已经" table1"用" id"和线几何列(" geom_line")。我想创建" table2"然后通过选择多边形内的所有线来填充它。我写了以下代码。请问有人纠正吗?

SELECT id, ST_Intersection(ST_GeomFromText('POLYGON((443425 4427680, 441353 4427680, 441368 4426075, 443762 4426149, 443425 4427680))', 32650)
, geom_line)
    FROM trajectory where geom_line IS NOT null

INTO table2 来自mydatabase

2 个答案:

答案 0 :(得分:3)

使用标准SQL中的F/libc (13733): Fatal signal 11 (SIGSEGV) at 0x00000005 (code=1), thread 13772 (myApp323408) I/DEBUG ( 178): pid: 13733, tid: 13772, name: myApp323408 >>> com.ionicframework.myApp323408 <<< W/ActivityManager( 529): Force finishing activity com.ionicframework.myApp323408/.MainActivity W/InputDispatcher( 529): channel '22441548 com.ionicframework.myApp323408/com.ionicframework.myApp323408.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0xd E/InputDispatcher( 529): channel '22441548 com.ionicframework.myApp323408/com.ionicframework.myApp323408.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed! I/ActivityManager( 529): Process com.ionicframework.myApp323408 (pid 13733) has died. W/InputDispatcher( 529): Attempted to unregister already unregistered input channel '22441548 com.ionicframework.myApp323408/com.ionicframework.myApp323408.MainActivity (server)' I/WindowState( 529): WIN DEATH: Window{22441548 u0 id=0 com.ionicframework.myApp323408/com.ionicframework.myApp323408.MainActivity} I/ActivityManager( 529): [TopPkgCurBat] NowPkgName[com.asus.launcher] Battery[39] TimeTick[1440510555542] OldPkgName[com.ionicframework.myApp323408] I/cm.log.servpro( 1129): [Privacy]/ com.ionicframework.myApp323408 is not in contact list I/KRCMD (16987): [MESSAGE] the exit process ok:com.ionicframework.myApp323408 D/LauncherLog( 927): AppsCustomizePagedView - syncAppsPageItems page: 5 index: 81 Item: myApp 创建基于select的表 - Postgres也支持这一点:

create table ... as select ...

手册中的更多细节:
http://www.postgresql.org/docs/current/static/sql-createtableas.html

答案 1 :(得分:0)

以下也是您需求的选项之一(在MS-SQL中支持)

SELECT ColumnName1,ColumnName1 INTO TableTest FROM Your_Table