Search code examples
databasedb2db2-luwinfluxdb-2

when create table inside database using db2 i get error SQL0007N?


I work on db2 database . I get error when create table inside database but I don't know how to solve this error .

I create table from db2 command windows Administrator

text file TestTables.sql contain query need executed by db2 as below

Create TABLE books (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL , author VARCHAR(255)  NOT  NULL , title VARCHAR(255)   NOT  NULL , isbn INT  NULL , PRIMARY KEY(id));

what I try

db2 => tvf C:\Users\MBR\Desktop\TestTables.sql
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0007N  The statement was not processed because a character that is not
supported in SQL statements was included in the SQL statement.  Invalid
character: "\".  Text preceding the invalid character: "tvf C:".
SQLSTATE=42601

so How to solve this error please ?


Solution

  • To me, it looks as if calling the .sql file by specifying the whole path ("C:\Users\MBR\Desktop\TestTables.sql") is wrong.

    Invalid character: "\".  Text preceding the invalid character: "tvf C:".
    

    Try to change current directory to Desktop, and then call the file without folder name.

    c:\temp>cd c:\users\mbr\desktop
    

    Documentation says

    Read from Input File Option (-f):

    The -f filename option tells the command line processor to read input from a specified file, instead of from standard input. Filename is an absolute or relative file name can include the directory path to the file. If the directory path is not specified, the current directory is used.