Tito Ciuro <[EMAIL PROTECTED]> writes:

> Hello,
>
> A few days ago I posted a question and I haven't seen any comments so
> far. I'm really curious about ROWID's volatility. How can I make sure that
> ROWIDs do not get re-initialized? I'm posting the message once again hoping
> that someone will explain how I should properly use ROWIDs.

If you declare an INTEGER PRIMARY KEY then it will be used as the ROWID:

    sqlite> CREATE TABLE test
       ...> (
       ...>   id INTEGER PRIMARY KEY,
       ...>   t  TEXT
       ...> );
    sqlite> INSERT INTO test VALUES (23, 'hello');
    sqlite> INSERT INTO test VALUES (42, 'world');
    sqlite> SELECT id, t FROM test;
       id = 23
        t = hello

       id = 42
        t = world
    sqlite> SELECT ROWID, t FROM test;
    ROWID = 23
        t = hello

    ROWID = 42
        t = world
    sqlite> .dump
    BEGIN TRANSACTION;
    CREATE TABLE test
    (
      id INTEGER PRIMARY KEY,
      t  TEXT
    );
    INSERT INTO test VALUES(23,'hello');
    INSERT INTO test VALUES(42,'world');
    COMMIT;
    sqlite>

Note that whether I select 'id' or 'ROWID', I get the same value.  Also note
that the .dump command generates a script that will recreate exactly the same
data as I did initially, so ROWID will have the same value after a re-create
as it does initially.

Derrell

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to