Solved

create a table from db2 command line

Posted on 2006-11-22
5
962 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 45

Accepted Solution

by:
Kent Olsen 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:Kent Olsen
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

696 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