Search code examples
indexingfirebirdcreate-table

Firebird: Adding Index in Create Table Statement


I've serach the many websites about firebird, but couldn't find an answer to my question.

I'm using ado .net for creating a table in firebird. And I want to create an index for one of the fields while creating the table:

Fbsql = "CREATE TABLE TEST( " +
        "TEST_ID Integer NOT NULL, " +
        "DESCRIPTION Varchar(15), " +
        "PRIMARY KEY (TEST_ID) " + 
        "USING DESCENDING INDEX IDX_DESC ON TEST (DESCRIPTION)); ";

But this code doesn't work, I get an "Token unknown" error on the word "on". What would be the right way to do this if possible?


Solution

  • No, this doesn't work. If you want to create an index, you need to do that in a separate create index statement.

    The only indexes that can be created in a create table are those created automatically for primary, unique and foreign keys.

    The using-clause in your question is to control the creation of the index (mainly name) backing one of those keys. It can't be used to create additional indexes.