SQL - lucasjwilber/seattle-301d52 GitHub Wiki
SQL is similar to regex, but used to find data in a table rather than a string. Unlike regex, SQL is much more semantic and legible. An example SQL query is "SELECT Names FROM Directory WHERE Age>=18;", which would find all the adults in a list of people.
Selecting data: SELECT [columnx, columny]/* FROM [tableName] WHERE [filter conditions]; *SELECT DISTINCT x" will remove duplicate values of x.
Inserting a row: INSERT INTO [table] VALUES [column1value, column2value, etc];
Updating a row: UPDATE [tableName] SET [columnx]=newValue, [columnY]=newValue WHERE [conditions];
Deleting a row: DELETE FROM [tableName] WHERE [conditions];
Creating a new table: CREATE TABLE IF NOT EXISTS [tableName] ( column1 [DATATYPE] [TableConstraint] DEFAULT [default_value], //<--the schema another_column [DATATYPE] [TableConstraint] DEFAULT [default_value], //constraints and defaults are optional );
Adding and removing columns: ALTER TABLE [tableName] ADD [columnName] [DATATYPE] [TableConstraint] DEFAULT [default_value] DROP [column to remove];
Re-naming the table: ALTER TABLE [tableName] RENAME TO [newName];
Deleting a table and its data and schema: DROP TABLE IF EXISTS [tableName];