|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Is there any way to detect, based strictly on querying the
structure of a table/database whether there is an AUTOINCREMENT set? That is to say, without analyzing the original SQL creation statement, and without inserting a new element into the database. Consider: CREATE Table myTab (col1 INTEGER AUTOINCREMENT PRIMARY KEY) vs. CREATE Table myTab (col1 INTEGER PRIMARY KEY) I have not found a difference upon looking at: SELECT * FROM sqlite_master WHERE type='table' AND name='myTab'; PRAGMA table_info('myTab'); The following is empty: PRAGMA index_list('myTab'); so index_info does not seem relevant either. Thanks, Csaba Gabor from Vienna |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Csaba Gabor write:
> Is there any way to detect, based strictly on querying the > structure of a table/database whether there is an > AUTOINCREMENT set? That is to say, without analyzing > the original SQL creation statement, and without inserting > a new element into the database. > Run 'DESCRIBE myTable' query, search 'Extra' field for 'auto_increment' value. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Jun 16, 1:43 pm, Alexey Kulentsov <a...@inbox.ru> wrote:
> Csaba Gabor write:> Is there any way to detect, based strictly on querying the > > structure of a table/database whether there is an > > AUTOINCREMENT set? That is to say, without analyzing > > the original SQL creation statement, and without inserting > > a new element into the database. > > Run 'DESCRIBE myTable' query, search 'Extra' field for > 'auto_increment' value. My apologies, I should have specified that this is exclusively for SQLite databases, and not for mySQL or others. Csaba |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Mon, 16 Jun 2008 09:21:22 -0700 (PDT), Csaba Gabor wrote:
> On Jun 16, 1:43 pm, Alexey Kulentsov <a...@inbox.ru> wrote: >> Csaba Gabor write:> Is there any way to detect, based strictly on querying the >> > structure of a table/database whether there is an >> > AUTOINCREMENT set? That is to say, without analyzing >> > the original SQL creation statement, and without inserting >> > a new element into the database. >> >> Run 'DESCRIBE myTable' query, search 'Extra' field for >> 'auto_increment' value. > > My apologies, I should have specified that this is > exclusively for SQLite databases, and not for mySQL > or others. http://www.sqlite.org/faq.html#q1 "(1) How do I create an AUTOINCREMENT field. Short answer: A column declared INTEGER PRIMARY KEY will autoincrement." Combine this knowlege with the PRAGMA calls about indexes and tables from http://www.sqlite.org/pragma.html#schema and you should have your answer. Sorry, I can't get more specific since I don't know anything about sqlite. I just know how to run a websearch. -- 95. My dungeon will have its own qualified medical staff complete with bodyguards. That way if a prisoner becomes sick and his cellmate tells the guard it's an emergency, the guard will fetch a trauma team instead of opening up the cell for a look. --Peter Anspach's Evil Overlord List |
|
![]() |
| Outils de la discussion | |
|
|