kvk30
kvk30

Reputation: 1203

Token unknown in SQLCODE

CREATE DATABASE test.fdb -user ZZZZZ -password *******;

I am using above command to create a database for my project in windows 7. I am new to Firebird SQL, I used my system credentials for log in but it is showing some error. So, How can I reset my password?

SQL error code = -104
Token unknown. 

I don't even know the significance of SQLCODE = -104.

Upvotes: 5

Views: 2948

Answers (1)

Mark Rotteveel
Mark Rotteveel

Reputation: 109239

The error shown is not caused by not knowing the database password, you have a syntax error in the CREATE DATABASE statement. The error Token unknown means that the statement parser read something it didn't expect; the error is usually followed by the offending token.

If I execute your statement using ISQL on Firebird 3.0, I get the following full error:

SQL> CREATE DATABASE test.fdb -user SYSDBA -password *******;
Statement failed, SQLSTATE = 42000
SQL error code = -104
-Token unknown
-test

Which means that at (or before) test something in your query is wrong.

The right syntax for CREATE DATABASE is:

 CREATE {DATABASE | SCHEMA} '<filespec>'
 [USER 'username' [PASSWORD 'password']]
 [PAGE_SIZE [=] size]
 [LENGTH [=] num [PAGE[S]]
 [SET NAMES 'charset'] 
 [DEFAULT CHARACTER SET default_charset
   [COLLATION collation]] -- not supported in ESQL
 [<sec_file> [<sec_file> ...]]
 [DIFFERENCE FILE 'diff_file']; -- not supported in ESQL

 <filespec> ::= [<server_spec>]{filepath | db_alias}

 <server_spec> ::= servername [/{port|service}]: | \\servername\

 <sec_file> ::= FILE 'filepath'
 [LENGTH [=] num [PAGE[S]] [STARTING [AT [PAGE]] pagenum]

In other words your statement should be:

create database 'test.fdb' user SYSDBA password '*******';

So:

  • Quotes around the path to the database file (or alias)
  • No - before the user and password clause
  • Quotes around the password (contrary to the syntax shown, quotes are optional around the user name)

As an aside, the SQL error code is usually not very interesting (as some of them can cover several different errors).

Upvotes: 2

Related Questions