T
T
toster182020-12-11 14:52:20
PHP
toster18, 2020-12-11 14:52:20

How to check if a column in sqlite3 is autoincrement?

I make a request
PRAGMA table_info(table_name)

I receive

[0]=>
  int(0)
  ["cid"]=>
  int(0)
  [1]=>
  string(2) "id"
  ["name"]=>
  string(2) "id"
  [2]=>
  string(7) "INTEGER"
  ["type"]=>
  string(7) "INTEGER"
  [3]=>
  int(0)
  ["notnull"]=>
  int(0)
  [4]=>
  NULL
  ["dflt_value"]=>
  NULL
  [5]=>
  int(0)
  ["pk"]=>
  int(0)


But how do you know if a column is auto-incrementing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nokimaro, 2020-12-11
@nokimaro

SELECT COUNT(*) FROM sqlite_sequence WHERE name='table_name';

you can also look at the contents of the tablesqlite_master
select tbl_name from sqlite_master where sql like '%autoincrement%'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question