create table table1 as select .. from sysibm.sysdummy1

青春壹個敷衍的年華 提交于 2019-12-11 23:26:44

问题


In DERBY,

I have a table which name is TEST1. I can run this code perfectly.

CREATE TABLE Table1 AS (SELECT * FROM TEST1) with no data

But I can't run this code and derby.

CREATE TABLE Table1 AS (SELECT ..... FROM sysibm.sysdummy1) with no data

editor throws this error :

ERROR: The CREATE TABLE statement does not include a column list.

ps: "SELECT ..... FROM sysibm.sysdummy1" works with no problem.

How can I create a table with using "select 'columns' from sysibm.sysdummy1" ?


回答1:


in my first code

CREATE TABLE Table1 AS (SELECT ..... x, y, z , 0 FROM sysibm.sysdummy1) with no data

I deleted comma and 0 in query and fixed it! Like that

CREATE TABLE Table1 AS (SELECT ..... x, y, z FROM sysibm.sysdummy1) with no data



回答2:


I think the problem may be that the "dummy" table has no columns, and since you specified no columns in your CREATE TABLE statement, Derby is trying to use the columns from the dummy table, and failing to find any, and saying "does not include a column list".

Why not specify the columns you desire in your result table?

For (a little bit) more information about the dummy table, see: http://apache-database.10148.n7.nabble.com/SYSIBM-schema-td74269.html



来源:https://stackoverflow.com/questions/20262352/create-table-table1-as-select-from-sysibm-sysdummy1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!