記事:
CREATE TABLE t1(a ANY) STRICT; INSERT INTO t1 VALUES('000123'); SELECT typeof(a), quote(a) FROM t1; -- result: text '000123'
sqlite3 mydb.db .dump | gzip > mydb.$(date '+%w').gz
zcat mydb.$(date '+%w').gz | sqlite3 mydb.db
sqlite3 mydb.db ".backup mydb.$(date '+%w').db" # オプションを追加して実行したい時。例:1秒待つ echo -e ".timeout 1000\n.backup mydb.$(date '+%w').db" | sqlite3 mydb.db
sqlite3 mydb.db ".restore mydb.$(date '+%w').db"
sqlite3 trac.db vacuum sqlite3 trac.db reindex
sqlite3 new.db sqlite> ATTACH DATABASE 'old.db' AS old; sqlite> .databases seq name file --- --------------- ---------------------------------------------------------- 0 main /tmp/new.db 2 old /tmp/old.db sqlite> BEGIN; sqlite> INSERT INTO main.table1(c1,c2,c3) SELECT c1,c2,c3 FROM old.table1; sqlite> COMMIT; sqlite> DETACH DATABASE old;
pecl install sqlite running: phpize Cannot find config.m4. Make sure that you run '/usr/bin/phpize' in the top level source directory of the module ERROR: `phpize' failed
cd /tmp wget http://pecl.php.net/get/SQLite-1.0.3.tgz tar xzf SQLite-1.0.3.tgz cd SQLite-1.0.3 phpize ./configure patch < sqlite.c.1.03.patch make make install cat > /etc/php.d/sqlite.ini << EOS extension=sqlite.so EOS service httpd restart 確認 php -m | grep sqlite pdo_sqlite sqlite
sqlite3 foo.db sqlite> CREATE TABLE item (id INT, name text); sqlite> .tables item sqlite> INSERT INTO item VALUES (1, 'item1'); sqlite> INSERT INTO item VALUES (2, 'item1'); sqlite> .exit ---- sqlite3 bar.db sqlite> CREATE TABLE item (id INT, name text); sqlite> .tables item sqlite> INSERT INTO item VALUES (3, 'item3'); sqlite> INSERT INTO item VALUES (4, 'item4'); ---- sqlite> attach 'foo.db' AS foo; sqlite> attach 'bar.db' AS bar; sqlite> SELECT * FROM foo.item UNION ALL SELECT * FROM bar.item; 1|item1 2|item2 3|item3 4|item4 sqlite> detach bar; sqlite> detach foo;