Multiple files for a single SQLite database

I found out, that it is possible. Use: sqlite3.exe MainDB.db ATTACH DATABASE ‘SomeTableFile.db’ AS stf; Access the table from the other database file: SELECT * FROM stf.SomeTable; You can even join over several files: SELECT * FROM MainTable mt JOIN stf.SomeTable st ON (mt.id = st.mt_id); https://www.sqlite.org/lang_attach.html tameera said there is a limit of 62 … Read more

Standard Deviation for SQLite

You can calculate the variance in SQL: create table t (row int); insert into t values (1),(2),(3); SELECT AVG((t.row – sub.a) * (t.row – sub.a)) as var from t, (SELECT AVG(row) AS a FROM t) AS sub; 0.666666666666667 However, you still have to calculate the square root to get the standard deviation.

SQLite Select from where column contains string?

SELECT * FROM users WHERE column LIKE ‘%mystring%’ will do it. LIKE means we’re not doing an exact match (column = value), but doing some more fuzzy matching. “%” is a wildcard character – it matches 0 or more characters, so this is saying “all rows where the column has 0 or more chars followed … Read more

SQLite list ALL foreign keys in a database

It seems that all (or many) of the PRAGMA commands can be programatically selected with a little trick; Usually the are called like: PRAGMA table_info(‘my_table’); PRAGMA foreign_key_list(‘my_table’); But this can also be done: SELECT * FROM pragma_table_info(‘my_table’); SELECT * FROM pragma_foreign_key_list(‘my_table’); And the schema can also be (more or less) obtained: .schema pragma_table_info /* pragma_table_info(cid,name,type,”notnull”,dflt_value,pk) … Read more

SQLITE3 VACUUM, “database or disk is full”

To allow the VACUUM command to run, change the directory for temporary files to one that has enough free space. SQLite’s documentation says the temporary directory is (in order): whatever is set with the PRAGMA temp_store_directory command; or whatever is set with the SQLITE_TMPDIR environment variable; or whatever is set with the TMPDIR environment variable; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)