The following SQL code works very well on MYSQL, and it contains valid SQL query language. However this doesn't work on embedded Firebird server.
The SQL code:
CREATE TABLE publications (
id int(11) NOT NULL,
filename varchar(500) NOT NULL,
title varchar(500) DEFAULT NULL,
authors varchar(1000) DEFAULT NULL,
uploader int(7) DEFAULT NULL,
keywords varchar(500) DEFAULT NULL,
rawtext text,
rawbinarydata blob NOT NULL,
lastmodified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
ALTER TABLE publications
ADD PRIMARY KEY (id),
ADD UNIQUE KEY filename (filename);
ALTER TABLE publications
MODIFY id int(11) NOT NULL AUTO_INCREMENT;
The C# code that is using the query is:
try
{
using( cmd.Connection = connect_to_fbserver() )
{
cmd.CommandText = fresh_db_creation_statement;
cmd.Connection.Open();
cmd.ExecuteNonQuery();
}
return true;
}
catch( Exception exx )
{
lasterror = exx.Message;
return false;
}
fresh_db_creation_statement
is the sql code in the first code listing.
The error was caught at lasterror = exx.Message;
with the value: "Dynamic SQL Error\nSQL error code = -104\nToken unknown - line 2, char 13"
, meaning the (
was flagged by the embedded firebird (that is line 2, char 13
).
When I removed all sizes of the defined data value types (e.g. changed id int(11) NOT NULL
to id int NOT NULL
) it will flag the NOT
.
How can I make Firebird accept this query and execute as normal?
AUTO_INCREMENT
does not have a replacement). Does it mean that ANSI SQL does not supportAUTO_INCREMENT
? – Hilarius