myhelp:sql
**This is an old revision of the document!**
SQLite
The Standard stuff is pretty easy. There is also a good summeray. Here we go with a quick start to create a DB-file with a table in it and do some stuff.
# sqlite3
sqlite> .table mydb.db
sqlite> CREATE TABLE IF NOT EXISTS T_names(name TEXT, birthyear INT);
sqlite> INSERT INTO T_names VALUES ('John Smith', 1999);
sqlite> INSERT INTO T_names VALUES ('Jack Doe', 1998);
sqlite> SELECT * FROM T_names;
sqlite> SELECT name FROM T_names WHERE birthyear=1998;
sqlite> UPDATE T_names SET birthyear=1997 WHERE name = 'Jack Doe';
sqlite> SELECT * FROM T_names LIMIT 1;
PostgreSQL
A useful tutorial is here.
Create, drop and list DB
CREATE DATABASE dbname; DROP DATABASE dbname; \l #List DBs
Connect to DB
\c dbname #Connect to DB
Select with multiple LIKE and NOT LIKE
SELECT something, anything FROM T_table WHERE something != 'thing' AND anything LIKE '%any%' AND anything NOT LIKE '%stuff%' AND anything NOT LIKE '%other%'; SELECT something, anything FROM T_table WHERE something LIKE ANY (ARRAY['%som%', '%thing', 'any%', 'stuff%'])
myhelp/sql.1683116087.txt.gz · Last modified: by ulrich
