View on GitHub

reading-notes

CodeFellows Class Reading Notes

SQLBolt

SQLBolt is an interactive teaching tool to introduce users to SQL. Below, I’ve compiled notes taken during the provided exercises:

SELECT queries 101

The syntax used is

SELECT column FROM table;

Queries with constraints

SELECT column FROM table WHERE condition;

Filtering and sorting Query results

SELECT DISTINCT column FROM table WHERE condition;

-ORDER BY allows us to sort rows alpha-numerically, ascending or descending

SELECT column FROM table WHERE condition ORDER BY column ASC/DESC;

Inserting rows

Database Schema describes the structure of each table, and the datatypes that each column of the table can contain

INSERT statements are used to insert data into the database:

INSERT INTO table VALUES (value)

Updating rows

UPDATE can be used to update existing data - the data must match the data type of the columns in the table schema

UPDATE table SET column = value WHERE condition;

Deleting rows

DELETE statement can be used to delete rows:

DELETE FROM table WHERE condition;

Creating tables

CREATE TABLE statement can be used to create a new database table

CREATE TABLE IF NOT EXISTS table(column DataType TableConstraint DEFAULT default_value);

Altering tables

ALTER TABLE statement allows you to add, remove, or modify columns and table constraints

ALTER TABLE table RENAME TO newTableName;

Dropping tables

DROP TABLE removes the entire table including all of its data and metadata

DROP TABLE IF EXISTS table;


Home