Solved

create a table from db2 command line

Posted on 2006-11-22
5
920 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now