in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

Data type not inherited when creating tables by CREATE TABLE x AS SELECT * FROM y WHERE ...

Last post 07-30-2009 7:45 AM by Robert Simpson. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-30-2009 4:40 AM

    Data type not inherited when creating tables by CREATE TABLE x AS SELECT * FROM y WHERE ...

    I've found this BUG with1.0.65, later I checked with 1.0.63, but it performs the same.
    When creating tables using CREATE TABLE x AS SELECT * FROM y WHERE ... the created table does not inherit the data types of the original table!

    for example:

    The original 'BinaryAttachment' is:

    CREATE TABLE "BinaryAttachment"
    (
        binaryAttachment_ID UNIQUEIDENTIFIER PRIMARY KEY NOT NULL,
        binaryAttachmentType_ID INTEGER(1) NOT NULL,
        name TEXT(50) NOT NULL,
        description TEXT(400),
        rowStatus INTEGER(1) NOT NULL,
        binaryData BLOB NOT NULL,
        dataSize INTEGER(4) NOT NULL,
        creationTime DATETIME NOT NULL
    );

    After filtering some rows into a TEMP table using
    CREATE TABLE tmp_BinaryAttachment_15_5e6c86 AS SELECT * FROM BinaryAttachment WHERE ...
    the created temp table has this declaration:

    CREATE TABLE tmp_BinaryAttachment_15_5e6c86(
      binaryAttachment_ID NUM,
      binaryAttachmentType_ID INT,
      name TEXT,
      description TEXT,
      rowStatus INT,
      binaryData,
      dataSize INT,
      creationTime NUM
    );

    The first problem is that (i think) the created table should have the same types as the original table.
    The second problem is (as you can see), the type of the 'binaryData' column is not declared!

  • 07-30-2009 7:45 AM In reply to

    Re: Data type not inherited when creating tables by CREATE TABLE x AS SELECT * FROM y WHERE ...

    This is not a .NET bug, it's a limitation in the underlying SQLite engine I'm afraid.  Executing this same code against the command-line sqlite3.exe utility from sqlite.org will get you the exact same results.

    SQLite understands types in a very limited fashion, so it has trouble with these kinds of queries that dynamically build a table.  I think there are some outstanding bug reports on the sqlite.org website on this...but I'm not sure if it'll be fixed.

     

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems