473,385 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

SQLite and detecting AUTOINCREMENT

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
Jun 27 '08 #1
3 3776
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.
Jun 27 '08 #2
On Jun 16, 1:43 pm, Alexey Kulentsov <a...@inbox.ruwrote:
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
Jun 27 '08 #3
On Mon, 16 Jun 2008 09:21:22 -0700 (PDT), Csaba Gabor wrote:
On Jun 16, 1:43 pm, Alexey Kulentsov <a...@inbox.ruwrote:
>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
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dennis | last post by:
I have set a DataTable and one of the columns I set "AutoIncrement" to True. I then populate the Table by setting the columns to values then add the row to the table. I inadverently set the...
12
by: John Salerno | last post by:
I've been looking around and reading, and I have a few more questions about SQLite in particular, as it relates to Python. 1. What is the current module to use for sqlite? sqlite3? or is that not...
4
by: Tim | last post by:
Hello All, I could use some help on an error that is just now popping it's head up. Seems that the autoincrement numeric has hit 32,767. The autoincrement is used in various locations in the...
0
by: smitty1e | last post by:
Disclaimer(s): the author is nobody's pythonista. This could probably be done more elegantly. The driver for the effort is to get PyMacs to work with new-style classes. This rendering stage...
3
by: Daniel Fetchinson | last post by:
Does Python 2.5.2's embedded SQLite support full text searching? Sqlite itself is not distributed with python. Only a python db api compliant wrapper is part of the python stdlib and as such it...
2
by: Gandalf | last post by:
I'm trying to convert mysql database to sqlite. is their any free tool that does that? I can convert my mysql db to XML file through phpmyadmin, will it be easier to convert from XML to SQlite...
0
by: Joe Goldthwaite | last post by:
Thanks Guilherme. That helped. I guess I was thinking that pysqlite would automatically come with some version of sqlite. The fact that it doesn't is what was causing me to get the strange...
20
by: timotoole | last post by:
Hi all, On a (sun) webserver that I use, there is python 2.5.1 installed. I'd like to use sqlite3 with this, however sqlite3 is not installed on the webserver. If I were able to compile sqlite...
1
dlite922
by: dlite922 | last post by:
I'm trying to convert an SQLITE database to MySQL syntax and it seems every resource I find on google is only half complete. I want to create this thread to sum them all up in one central...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.