Simon,

On Mon, Nov 16, 2015 at 3:13 PM, Simon Slavin <slavins at bigfraud.org> wrote:
>
> On 16 Nov 2015, at 7:40pm, Igor Korot <ikorot01 at gmail.com> wrote:
>
>> But if I issue this PRAGMA command the field name, field type and the PK
>> are guaranteed to have some values, right?
>
> No.  Create a field without a declared type and use that as your primary key.
>
>> You can't create a field without a name
>
> Correct.  At least I think so.
>
>> or the type
>
> Wrong.
>
> 178:~ simon$ sqlite3 ~/Desktop/fred.sql
> SQLite version 3.8.10.2 2015-05-20 18:17:19
> Enter ".help" for usage hints.
> sqlite> CREATE TABLE myTable (fred PRIMARY KEY);
> sqlite> PRAGMA table_info(myTable);
> 0|fred||0||1
> sqlite> PRAGMA index_list(myTable);
> 0|sqlite_autoindex_myTable_1|1|pk|0
> sqlite> PRAGMA index_info(sqlite_autoindex_myTable_1);
> 0|0|fred
> sqlite> PRAGMA index_xinfo(sqlite_autoindex_myTable_1);
> 0|0|fred|0|BINARY|1
> 1|-1||0|BINARY|0
> sqlite>
>
> I'd like to emphasise something Scott Hess wrote.  There is considerable 
> leeway in the documentation for PRAGMAs and things can change from one 
> version of SQLite to another.  Pragmas like this are for use only when you 
> don't know the answers.  For example for database management software which 
> has to operate on any SQLite database.

Let's go to the example (I understand better this way):

sqlite> PRAGMA table_info(leagues);
cid|name            |type           |notnull|  dflt_value|pk
  0|id                  |integer       |0      |                  |1
  1|name            |varchar(100)|0      |                  |0
  2|drafttype       |integer(1)    |0      |                  |0
  3|scoringtype   |integer(1)    |0      |                  |0
  4|roundvalues   |integer(1)    |0      |                  |0
  5|leaguetype    |char(5)        |0      |                 |0
  6|salary           |integer        |0      |                  |0
  7|benchplayers|integer(1)     |0      |                  |0

In this output the field name is always will have a value. The field
"type" may or may not have it.
The "notnull" field I believe also will always have a value - if one
won't set it on the table creation,
the engine will assign it.
"dflt_value" field may or may not have a value.
And finally a "pk" field will always have a value - it is a boolean
field which wil be defined either
by the programmer or engine.
Am I right?

Thank you.

BTW, you don't have to make a field primary key in order for it not to
have a type.
I guess its just a beauty of the SQLite engine.

And of course those things should be documented somewhere -
inconsistencies between PRAGMA's in different
SQLite versions.



>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to