sqlite> select rowid from table_name;で行番号表示。
sqlite> update table_name set id = rowid;
で投入完了。
なんちゃってauto incrementのできあがり。
sqlite> select rowid from table_name;で行番号表示。
sqlite> update table_name set id = rowid;
SQLiteでのPDO、bindParamの書き方が、に載っていて、とても簡単だったので、引用メモです。
<?php
$stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (:name, :value)");
$stmt->bindParam(':name', $name);
$stmt->bindParam(':value', $value);
// 行を挿入します
$name = 'one';
$value = 1;
$stmt->execute();
// パラメータを変更し、別の行を挿入します
$name = 'two';
$value = 2;
$stmt->execute();
?>
(11) How do I add or delete columns from an existing table in SQLite.
SQLite has limited ALTER TABLE support that you can use to add a column to the end of a table or to change the name of a table. If you want to make more complex changes in the structure of a table, you will have to recreate the table. You can save existing data to a temporary table, drop the old table, create the new table, then copy the data back in from the temporary table.
For example, suppose you have a table named "t1" with columns names "a", "b", and "c" and that you want to delete column "c" from this table. The following steps illustrate how this could be done:
BEGIN TRANSACTION;
CREATE TEMPORARY TABLE t1_backup(a,b);
INSERT INTO t1_backup SELECT a,b FROM t1;
DROP TABLE t1;
CREATE TABLE t1(a,b);
INSERT INTO t1 SELECT a,b FROM t1_backup;
DROP TABLE t1_backup;
COMMIT;
output_buffering = On
output_handler = mb_output_handler
default_charset = "Shift_JIS"
mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.http_output = SJIS
mbstring.detect_order = SJIS,EUC-JP,JIS,UTF-8,ASCII
mbstring.substitute_character = "none"
mbstring.encoding_translation = On