PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > SQLite and detecting AUTOINCREMENT
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
SQLite and detecting AUTOINCREMENT

Réponse
 
LinkBack Outils de la discussion
Vieux 16/06/2008, 09h29   #1
Csaba Gabor
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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
  Réponse avec citation
Vieux 16/06/2008, 12h43   #2
Alexey Kulentsov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: SQLite and detecting AUTOINCREMENT

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.
  Réponse avec citation
Vieux 16/06/2008, 17h21   #3
Csaba Gabor
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: SQLite and detecting AUTOINCREMENT

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
  Réponse avec citation
Vieux 16/06/2008, 17h36   #4
Peter H. Coffin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: SQLite and detecting AUTOINCREMENT

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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 10h51.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11389 seconds with 12 queries