Solved

create a table from db2 command line

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
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…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

18 Experts available now in Live!

Get 1:1 Help Now