Fundamentals
Literals
A literal is just a fixed value, written directly into a query, not a reference to anything else.
sql
SELECT 'Dune'; -- character literal
SELECT 42; -- integer literal
SELECT 3.14; -- real literal
SELECT title FROM movies; -- title, movies: no quotes, schema objects- Words or characters are character literals, wrapped in single or double quotes,
'Dune'or"Dune". - No quotes at all means it's not a literal, it's a reference to a schema object, a table name or column name, like
titleormoviesabove. - Numbers are numeric literals, split into two kinds: integer literals (whole numbers,
42) and real literals (numbers with a decimal point,3.14).
Listing databases
sql
SHOW DATABASES;A MySQL-specific admin command, not standard SQL, lists every database the current connection has access to on the server. Useful as a first step before USE <database> to pick which one to work in.
Creating and selecting a database
sql
CREATE DATABASE firstDb;
USE firstDb;CREATE DATABASE firstDbmakes a new, empty database on the server, just the container, no tables in it yet.USE firstDbswitches the current connection into that database. Every statement after this,CREATE TABLE,INSERT,SELECT, runs againstfirstDbuntil a differentUSEswitches elsewhere.