469,343 Members | 5,478 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

is an undefined name. SQLSTATE=42704

I am trying to create a table from an existing table and i need the existing tables data in my new table, So i submitted the following statement


insert into first (select * from <old_table>

but i am getting the following error

Error during Prepare
S0002(-204)[IBM][CLI Driver][DB2/AIX64] SQL0204N "RNOEL03.FIRST" is an undefined name. SQLSTATE=42704


can you please help

Thanks
Apr 24 '12 #1
7 14064
insert into first (select * from <old_table>)
Apr 24 '12 #2
Rabbit
12,516 Expert Mod 8TB
The correct syntax to create a table from a SELECT query is this:
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. INTO newTable
  3. FROM oldTable
Apr 24 '12 #3
i did that
select * into st from <old_table>

but i am getting this

error Error during Prepare
42601(-104)[IBM][CLI Driver][DB2/AIX64] SQL0104N An unexpected token "into st from <old_table>" was found following "select * ". Expected tokens may include: "<table_expr>". SQLSTATE=42601
Apr 24 '12 #4
I working on AQT tool on DB2
Apr 24 '12 #5
Rabbit
12,516 Expert Mod 8TB
You actually put in <>? I thought you were just doing that in place of the actual table name. Remove them, they are not correct syntax.
Apr 24 '12 #6
No i did not put < > i just replaced the real table name with that.
Apr 24 '12 #7
Rabbit
12,516 Expert Mod 8TB
It looks like DB2 does not support the SELECT INTO syntax to create tables. You'll have to use two SQL statements. One create statement and one insert statement.
Apr 24 '12 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Laygo | last post: by
5 posts views Thread by Jean-Marc Blaise | last post: by
6 posts views Thread by yoyo | last post: by
1 post views Thread by tmugavero | last post: by
138 posts views Thread by Ian Boyd | last post: by
8 posts views Thread by Brian Tkatch | last post: by
2 posts views Thread by uday123 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.