256 Kilobytes

[Infographic] The Beginner's SQLite Cheat Sheet

Articles in Web Scraping, Data Analysis | By August R. Garcia

Published 6 months agoSat, 04 May 2019 23:59:37 -0700

The important hotkeys, commands, and tricks for SQLite

326 views, 0 RAMs, and 0 comments

What a great infographic.

SQLite Cheat Sheet Infographic

Copy-Pasteable Version of the SQLite Commands Cheat Sheet

General SQLite Commands and Information

Opening SQLite

Default Open   - sqlite3
Open Database  - sqlite3 name.db

Read in SQL File

sqlite> .read file.sql

Output Formats

.mode column
.mode csv
.mode html
.mode insert
.mode line
.mode list
.mode tabs
.mode tcl

SQL Statements in SQLite

SELECT Statements

Everything

SELECT * FROM table_name;

First Ten Rows

SELECT * FROM table_name LIMIT 10;

Specify Conditions

SELECT * FROM table_name WHERE price > 100;

Match String that Starts with "D"

SELECT * FROM table_name WHERE name LIKE 'De%';

Specify Order

SELECT * FROM table_name ORDER BY name  ASC;
SELECT * FROM table_name ORDER BY name DESC;

INSERT Statements

INSERT INTO table_name (col1, col2) VALUES (20, "DOG");

UPDATE Statements

UPDATE table_name SET col1 = TRUE WHERE is_true = TRUE

DELETE Statements

DELETE from table_name WHERE is_bad <> TRUE;

Conditions

=       Equal
>       Greater than
<       Less Than
>=      Greater than or equal
<=      Less than or equal
<>      Not equal
BETWEEN Specify range
LIKE    Match part of string
IN      Is in a set of values

Create Table

CREATE TABLE table_name (
  id      INTEGER PRIMARY KEY AUTOINCREMENT,
  name    TEXT,
  cost    FLOAT,
  is_true BOOLEAN
);

Importing and Exporting in SQLite

Importing from CSV

sqlite> .mode csv
sqlite> .import file.csv table_name

Export to CSV

sqlite> .mode csv
sqlite> .output file.csv
sqlite> SELECT * FROM table;
sqlite> .output stdout

Download more RAM. 🐏 ⨉ 0 Posted by August R. Garcia 6 months ago 🕓 Posted at 04 May, 2019 23:59 PM PDT

Profile Photo - August R. Garcia August R. Garcia LARPing as a Sysadmi... Portland, OR
🗎 199 🗨 991 🐏 300
Site Owner

Grahew Mattham

August Garcia is some guy who used to sell Viagra on the Internet. He made this website to LARP as a sysadmin while posting about garbage like user-agent spoofing, spintax, the only good keyboard, virtual assitants from Pakistan, links with the rel="nofollow" attributeproxiessin, the developer console, literally every link building method, and other junk.

Available at arg@256kilobytes.com, via Twitter, or arg.256kilobytes.com. Open to business inquiries based on availability.


Account created 11 months ago.
199 posts, 991 comments, and 300 RAMs.

Last active 1 day ago:
Posted thread [Solved] Favicon.ico Files not Caching on Chrome

Post a New Comment

To leave a comment, login to your account or create an account.

Do you like having a good time?

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account
You can also login to an existing account or recover your password. All use of this site is subject to terms outlined in the terms of service and privacy policy.