Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6091643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:21:05+00:00 2026-05-23T12:21:05+00:00

I just imported a huge text file into a table, using the .import command.

  • 0

I just imported a huge text file into a table, using the .import command. Everything is OK, except for the fact that it seems to treat clearly numeric values as text. For instance, conditions such as WHERE field > 4 are always met. I did not specify datatypes when I created the table, but this doesn’t seem to matter when small tables are created.

Any advice would be welcome. Thanks!

Edit/conclusion: It turns out some of the values in my CSV file were blanks. I ended up solving this by being a bit less lazy and declaring the datatypes explicitly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:21:06+00:00Added an answer on May 23, 2026 at 12:21 pm

    The way SQLite handles types is described on this page: http://www.sqlite.org/datatype3.html

    In particular:

    Under circumstances described below,
    the database engine may convert values
    between numeric storage classes
    (INTEGER and REAL) and TEXT during
    query execution.

    Section 3.4 (Comparison Example) should give you concrete examples, which are likely to explain the problem you have. This is probably this example:

    -- Because column "a" has text affinity, numeric values on the
    -- right-hand side of the comparisons are converted to text before
    -- the comparison occurs.
    SELECT a < 40,   a < 60,   a < 600 FROM t1;
    0|1|1
    

    To avoid the affinity to be guessed, you can use CAST explicitly (see section 3.2 too):

    SQLite may attempt to convert values
    between the storage classes INTEGER,
    REAL, and/or TEXT before performing a
    comparison. Whether or not any
    conversions are attempted before the
    comparison takes place depends on the
    affinity of the operands. Operand
    affinity is determined by the
    following rules:

    • An expression that is a simple reference to a column value has the
      same affinity as the column. Note that
      if X and Y.Z are column names, then +X
      and +Y.Z are considered expressions
      for the purpose of determining
      affinity.
    • An expression of the form “CAST(expr AS type)” has an affinity
      that is the same as a column with a
      declared type of “type”.
    • Otherwise, an expression has NONE affinity.

    Here is another example:

    CREATE TABLE test (value TEXT);
    INSERT INTO test VALUES(2);
    INSERT INTO test VALUES(123);
    INSERT INTO test VALUES(500);
    
    SELECT value, value < 4 FROM test;
    2|1
    123|1
    500|0
    

    It’s likely that the CSV import create columns of affinity TEXT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just imported a chunk of text into a string element for a book
I've just imported a code file from my Netbeans project into an Eclipse project.
I have just imported a huge MySQL database. Most fields are latin1_swedish_ci, and they
I've just imported a Flex component into my project. I have a theory question
I just downloaded the Google Collections sources and imported them into a new Eclipse
I have a stack of code snippets imported into Visual Studio. Just recently, they
I've imported my mod_rewrite rules... everything works just fine... but seemingly randomly it deletes
I've just imported a bunch of data to a MySQL table and I have
I just imported my posts from blogger into wordpress. In doing this, the tags
I've just imported a large amount of source code into Eclipse and basically the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.