Solved

create a table from db2 command line

Posted on 2006-11-22
5
926 Views
Last Modified: 2012-08-13
hi ,

i tried to create a db2 table from command line in my local pc (windows xp) by using the following sql code :
firect i connect to the database: OSCTEST
in prompt of:  the db2=>

i paste the folloing sql code:

CREATE TABLE "TESTMEMBERDBSCHEMA"."TESTMEMBERKEYWPORD"  (
              "ID" INTEGER NOT NULL WITH DEFAULT 1 ,
              "KEYWORDS" VARCHAR(400) ,
              "ADDITIONALKEYWORDS" LONG VARCHAR NOT NULL ,
              "FIRSTNAME" VARCHAR(30) NOT NULL ,
              "MIDNAME" VARCHAR(20) ,
              "LASTNAME" VARCHAR(30) NOT NULL ,
              "TITLE" VARCHAR(150) NOT NULL ,
              "EMAIL" VARCHAR(50) NOT NULL ,
              "PROFILE" VARCHAR(200) )   ;

---------------------------------------------------

then i press the enter key. the result is:
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token "(" was found following "."TESTMEMBERKEYWPORD"".
Expected tokens may include:  "END-OF-STATEMENT".  SQLSTATE=42601
db2 =>            "ID" INTEGER NOT NULL WITH DEFAULT 1 ,
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token "INTEGER" was found following ""ID" ".  Expected
tokens may include:  "JOIN <joined_table>".  SQLSTATE=42601
db2 =>            "KEYWORDS" VARCHAR(400) , );
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token ""KEYWORDS" VARCHAR" was found following
"BEGIN-OF-STATEMENT".  Expected tokens may include:  "<values>".
SQLSTATE=42601

-------------------------------------------------------------

can someone help answer why there is error?  

i used almost the same sql code in linux to create the table. there is no error

thanks so much for your reply,

lilyyan



0
Comment
Question by:lilyyan
  • 2
  • 2
5 Comments
 
LVL 45

Accepted Solution

by:
Kdo earned 100 total points
ID: 17997350

Db2 expects the entire statement on one line.  That makes certain things pretty tough.

Fire up db2 with a different terminator character and you should be fine.  Oh, and leave off the final ';'

> db2 -td#
db2 => {paste the text here}
db2 => #
db2 => quit
db2 => #


Kent
0
 
LVL 37

Assisted Solution

by:momi_sabag
momi_sabag earned 100 total points
ID: 17997711
hi

you can just run db2 -t and it would work (this would make ; the command terminator instead of new line)
0
 
LVL 45

Expert Comment

by:Kdo
ID: 17997789

Cool.  Didn't know that.    :~}


0
 

Author Comment

by:lilyyan
ID: 17997945
thanks a lot, both works perfectly ^______^
0
 

Author Comment

by:lilyyan
ID: 17997964
could you please reply my another posting: create a table in db2cc
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question