3

Is there a pure sqlite request to find a string in a database ?

With a bit of shell, I can extract the schemas from the tables:

for i in *sqlite; 
   do sqlite3 $i ".tables"
   | grep -Eoh "[^ ]+" 
   | while read t; do 
          echo -n "$i:$t  ";
          sqlite3 $i '.schema "'"$t"'"';
   done;
echo;
done

Then I could find which column has the type TEXT, and make a request.

But is there a pure SQL way to do this in a terminal ?

1 Answer 1

3

TLDR; To dump a sqlite db to a file called dump.sql

sqlite3 some.db .dump > dump.sql

SQLite is designed as an embedded database and therefore does have only extremely basic programming capabilities (it has triggers, but no control logic like if or loops). So it is not possible to do anything dynamic in SQL – the result of PRAGMA table_info cannot be directly used in SQL queries.

A very quick and dirty way to search everywhere in a database is to show all contents with .dump and then just grep that. However, this isn't actually quick because searching indexed columns would be faster in SQL.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.