473,545 Members | 2,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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('myT ab');

The following is empty:
PRAGMA index_list('myT ab');
so index_info does not seem relevant either.

Thanks,
Csaba Gabor from Vienna
Jun 27 '08 #1
3 3790
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.ruw rote:
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.ruw rote:
>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_incremen t' 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
16111
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 AutoIncrement Columns to different values but didn't get any errors. Should I be able to set the value of an AutoIncrement Column? I would have thought...
12
2464
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 out until Python 2.5? 2. What's the difference between sqlite and pysqlite? Do you need both, just one, or is one an older version of the same...
4
2442
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 database, but in this case (log sheets), we have hit 32k log entries over the past 2 years. Is there a simple switch to set the autoincrement from...
0
1429
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 stands alone, and might be used for other purposes. A subsequent post will show using the resulting file to produce (I think valid) .el trampoline...
3
275
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 is completely independent of the sqlite build. In other words, if your sqlite build supports full text searching you can use it through the python...
2
4280
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 then from Mysql?
0
2564
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 results. I downloaded the Windows version of the SQLite3.dll. I didn't know where to put it so I first put it in its own directory and tried to...
20
3951
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 using a sun machine (I normally use linux machines) and place this in my lunix home account would I be able to use python and sqlite? Any...
1
8895
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 location; Finally a bulleted list of all the rules you have to apply to your script to completely and fully transfer /any/ sqlite schema dump to a MySQL one....
0
7502
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7434
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7692
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.