{
 "source": "https://peabody.kids/flashcards/tech-sql-commands",
 "id": "tech-sql-commands",
 "title": "SQL Commands",
 "category": "technology",
 "subject": "Databases",
 "levels": [
  "9-12",
  "college",
  "adult"
 ],
 "description": "Core SQL statements and database terms for querying and changing data.",
 "tags": [
  "SQL",
  "database",
  "queries"
 ],
 "frontLabel": "Command or term",
 "backLabel": "What it does",
 "cards": [
  [
   "SQL",
   "Structured Query Language, used to work with databases"
  ],
  [
   "Database",
   "An organized collection of data"
  ],
  [
   "Table",
   "Rows and columns of data in a database"
  ],
  [
   "Row (record)",
   "One entry in a table"
  ],
  [
   "Column (field)",
   "One attribute shared by all rows"
  ],
  [
   "Primary key",
   "A column that uniquely identifies each row"
  ],
  [
   "Foreign key",
   "A column linking to the primary key of another table"
  ],
  [
   "SELECT",
   "Gets data from a table"
  ],
  [
   "SELECT *",
   "Gets every column"
  ],
  [
   "FROM",
   "Names the table to read"
  ],
  [
   "WHERE",
   "Filters rows by a condition"
  ],
  [
   "AND, OR, NOT",
   "Combine or negate conditions"
  ],
  [
   "ORDER BY",
   "Sorts the results"
  ],
  [
   "ASC / DESC",
   "Sort ascending or descending"
  ],
  [
   "LIMIT",
   "Restricts how many rows are returned"
  ],
  [
   "DISTINCT",
   "Removes duplicate values from results"
  ],
  [
   "LIKE",
   "Matches text patterns"
  ],
  [
   "% wildcard",
   "Matches any number of characters in LIKE"
  ],
  [
   "_ wildcard",
   "Matches exactly one character in LIKE"
  ],
  [
   "IN",
   "Matches any value in a list"
  ],
  [
   "BETWEEN",
   "Matches a range of values"
  ],
  [
   "IS NULL",
   "Tests for missing values"
  ],
  [
   "AS (alias)",
   "Gives a column or table a temporary name"
  ],
  [
   "INSERT INTO",
   "Adds new rows to a table"
  ],
  [
   "VALUES",
   "Gives the values for an insert"
  ],
  [
   "UPDATE",
   "Changes data in existing rows"
  ],
  [
   "SET",
   "Names the columns to change in an update"
  ],
  [
   "DELETE FROM",
   "Removes rows"
  ],
  [
   "CREATE TABLE",
   "Makes a new table"
  ],
  [
   "ALTER TABLE",
   "Changes a table's structure"
  ],
  [
   "DROP TABLE",
   "Deletes a table entirely"
  ],
  [
   "CREATE INDEX",
   "Makes a table lookup faster"
  ],
  [
   "COUNT()",
   "Counts rows"
  ],
  [
   "SUM()",
   "Adds up values"
  ],
  [
   "AVG()",
   "Finds the average"
  ],
  [
   "MIN()",
   "Finds the smallest value"
  ],
  [
   "MAX()",
   "Finds the largest value"
  ],
  [
   "GROUP BY",
   "Groups rows to use with aggregate functions"
  ],
  [
   "HAVING",
   "Filters groups after grouping"
  ],
  [
   "JOIN",
   "Combines rows from two tables"
  ],
  [
   "INNER JOIN",
   "Keeps only rows that match in both tables"
  ],
  [
   "LEFT JOIN",
   "Keeps all rows from the left table and matches from the right"
  ],
  [
   "RIGHT JOIN",
   "Keeps all rows from the right table and matches from the left"
  ],
  [
   "FULL OUTER JOIN",
   "Keeps all rows from both tables"
  ],
  [
   "CROSS JOIN",
   "Pairs every row of one table with every row of another"
  ],
  [
   "UNION",
   "Combines results of two queries, removing duplicates"
  ],
  [
   "UNION ALL",
   "Combines results and keeps duplicates"
  ],
  [
   "Subquery",
   "A query inside another query"
  ],
  [
   "EXISTS",
   "Tests whether a subquery returns rows"
  ],
  [
   "CASE WHEN",
   "Conditional logic inside a query"
  ],
  [
   "NULL",
   "A missing or unknown value"
  ],
  [
   "NOT NULL",
   "A column must always have a value"
  ],
  [
   "UNIQUE",
   "All values in a column must be different"
  ],
  [
   "DEFAULT",
   "A value used when none is given"
  ],
  [
   "CHECK",
   "A rule that values must satisfy"
  ],
  [
   "Transaction",
   "A group of operations that succeed or fail together"
  ],
  [
   "COMMIT",
   "Saves a transaction"
  ],
  [
   "ROLLBACK",
   "Undoes a transaction"
  ],
  [
   "View",
   "A saved query that acts like a table"
  ],
  [
   "Index",
   "A structure that speeds up searches"
  ],
  [
   "Normalization",
   "Organizing tables to reduce repeated data"
  ],
  [
   "Schema",
   "The structure of a database"
  ],
  [
   "Relational database",
   "A database storing data in related tables"
  ],
  [
   "One-to-many relationship",
   "One row in a table relates to many rows in another"
  ],
  [
   "Many-to-many relationship",
   "Many rows relate to many, using a join table"
  ],
  [
   "ACID",
   "Atomicity, Consistency, Isolation, Durability, properties of reliable transactions"
  ],
  [
   "SQL injection",
   "An attack that sneaks harmful SQL into input; prevent with parameterized queries"
  ],
  [
   "Parameterized query",
   "A query with placeholders for safe user input"
  ],
  [
   "MySQL, PostgreSQL, SQLite",
   "Popular SQL database systems"
  ],
  [
   "NoSQL",
   "Databases that don't use traditional tables, like document stores"
  ],
  [
   "Query",
   "A request for data"
  ],
  [
   "CRUD",
   "Create, Read, Update, Delete"
  ]
 ]
}
