-----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Ted Rolle Sent: Friday, October 30, 2009 10:36 AM To: sqlite-users Subject: [sqlite] How to skip the first field on .import
The first field in my table is ID primary integer autoincrement. =====> Do you instead mean "INTEGER PRIMARY KEY AUTOINCREMENT" ? I read that if it is set to NULL it defaults to the maximum value possible. Not a Good Thing(tm). =====> Can you post the url where you read this? From page http://www.sqlite.org/autoinc.html it says something quite different: If no ROWID is specified on the insert, an appropriate ROWID is created automatically. The usual algorithm is to give the newly created row a ROWID that is one larger than the largest ROWID in the table prior to the insert. If the table is initially empty, then a ROWID of 1 is used. If the largest ROWID is equal to the largest possible integer (9223372036854775807) then the database engine starts picking candidate ROWIDs at random until it finds one that is not previously used. How do I let this start out at the default value and auto increment? My column separator is '|'. =====> I'm guessing you're using the command-line utility program. Others may have better answers, but: -- If you're restoring a table you've dumped previously, then you probably want the primary key values to be set explicitly to their previous values -- i.e., you don't want them to take on new values. -- If this is an initial data import, one way to do this is to ".import" to a temporary table withOUT the ID key, then use an sql command to transfer the data to the permanent table (which DOES use INTEGER PRIMARY KEY AUTOINCREMENT), e.g. INSERT INTO myPerm SELECT NULL, * FROM myTemp Donald _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users