tags:

views:

285

answers:

2

Hello,

i'm executing PRAGMA table_info over a sqlite db

PRAGMA table_info(my_table);

And these are the columns retrieved:

name type notnull dflt_value pk

I noted there is no column width in case of (n)(var)char data types, ¿is there any easy way to get this info?

NOTE: I know there is no problem inserting large values in these columns, however, i wanna access this metadata anyway.

A: 

From http://www.sqlite.org/faq.html#q9:

SQLite does not enforce the length of a VARCHAR. You can declare a VARCHAR(10) and SQLite will be happy to let you put 500 characters in it. And it will keep all 500 characters intact - it never truncates.

So basically, SQLite doesn't really have a length on those fields, it'll happily accept anything.

Epcylon
yeah, i know it, but he keeps a column width on the metadata (I use SQLite Expert and on the table design, he keeps the size of the column)
Jhonny D. Cano -Leftware-
A: 

When checking the content of the query result: PRAGMA table_info(my_table);

the type column contains

  • (n)(var)char for columns with width 1
  • (n)(var)char(x) for columns with width greater than 1
Jhonny D. Cano -Leftware-