Skip to content

Instantly share code, notes, and snippets.

@kzima
Forked from hofmannsven/README.md
Last active August 29, 2015 14:21
Show Gist options
  • Save kzima/a14aa79ea22a1a1aa533 to your computer and use it in GitHub Desktop.
Save kzima/a14aa79ea22a1a1aa533 to your computer and use it in GitHub Desktop.

Revisions

  1. kzima revised this gist May 24, 2015. No changes.
  2. @hofmannsven hofmannsven revised this gist Feb 19, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    MySQL
    ===============

    Getting started: http://www.sqlteaching.com/

    Related tutorial: http://cd64.de/mysql-cli

    SQL joins infografic: http://cd64.de/sql-joins
  3. @hofmannsven hofmannsven revised this gist Nov 8, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -52,6 +52,7 @@ Updating records: `UPDATE [table] SET [column] = '[updated-value]' WHERE [column
    Deleting records: `DELETE FROM [table] WHERE [column] = [value];`

    Delete *all records* from a table (without dropping the table itself): `DELETE FROM [table];`
    (This also resets the incrementing counter for auto generated columns like an id column.)

    Removing table columns: `ALTER TABLE [table] DROP COLUMN [column];`

  4. @hofmannsven hofmannsven revised this gist Nov 8, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -51,6 +51,8 @@ Updating records: `UPDATE [table] SET [column] = '[updated-value]' WHERE [column

    Deleting records: `DELETE FROM [table] WHERE [column] = [value];`

    Delete *all records* from a table (without dropping the table itself): `DELETE FROM [table];`

    Removing table columns: `ALTER TABLE [table] DROP COLUMN [column];`

    Deleting tables: `DROP TABLE [table];`
    @@ -61,4 +63,4 @@ Custom column output names: `SELECT [column] AS [custom-column] FROM [table];`

    Export a database dump (more info [here](http://stackoverflow.com/a/21091197/1815847)): `mysqldump -u [username] -p [database] > db_backup.sql`

    Logout: `exit`
    Logout: `exit;`
  5. @hofmannsven hofmannsven revised this gist Sep 11, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions my.cnf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    [mysqld]
    max_allowed_packet=64M
  6. @hofmannsven hofmannsven revised this gist Aug 3, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -59,6 +59,6 @@ Deleting databases: `DROP DATABASE [database];`

    Custom column output names: `SELECT [column] AS [custom-column] FROM [table];`

    Export a database dump (more info [here](http://stackoverflow.com/a/21091197/1815847)): `mysqldump -u [username] -p [database] > db_backup.sql` (will prompt for password)
    Export a database dump (more info [here](http://stackoverflow.com/a/21091197/1815847)): `mysqldump -u [username] -p [database] > db_backup.sql`

    Logout: `exit`
  7. @hofmannsven hofmannsven revised this gist Aug 3, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ SQL joins infografic: http://cd64.de/sql-joins
    Commands
    -----------

    Access monitor: `mysql -u [username] -p` (will prompt for password)
    Access monitor: `mysql -u [username] -p;` (will prompt for password)

    Show all databases: `show databases;`

    @@ -59,4 +59,6 @@ Deleting databases: `DROP DATABASE [database];`

    Custom column output names: `SELECT [column] AS [custom-column] FROM [table];`

    Export a database dump (more info [here](http://stackoverflow.com/a/21091197/1815847)): `mysqldump -u [username] -p [database] > db_backup.sql` (will prompt for password)

    Logout: `exit`
  8. @hofmannsven hofmannsven revised this gist Mar 4, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,8 @@ MySQL

    Related tutorial: http://cd64.de/mysql-cli

    SQL joins infografic: http://cd64.de/sql-joins


    Commands
    -----------
  9. @hofmannsven hofmannsven revised this gist Feb 23, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    MySQL Command Line Interface
    MySQL
    ===============

    Related tutorial: http://cd64.de/mysql-cli
  10. @hofmannsven hofmannsven revised this gist Feb 23, 2014. 1 changed file with 27 additions and 15 deletions.
    42 changes: 27 additions & 15 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -11,38 +11,50 @@ Access monitor: `mysql -u [username] -p` (will prompt for password)

    Show all databases: `show databases;`

    Access database: `mysql -u [username] -p [name-of-database]` (will prompt for password)
    Access database: `mysql -u [username] -p [database]` (will prompt for password)

    Create new database: `create database [name-of-database];`
    Create new database: `create database [database];`

    Select database: `use [name-of-database];`
    Select database: `use [database];`

    Show all tables: `show tables;`

    Show table structure: `describe [name-of-table];`
    Show table structure: `describe [table];`

    Create new table with columns: `CREATE TABLE [name-of-table] ([name-of-column] VARCHAR(120), [name-of-another-column] DATETIME);`
    Create new table with columns: `CREATE TABLE [table] ([column] VARCHAR(120), [another-column] DATETIME);`

    Adding a column: `ALTER TABLE [name-of-table] ADD COLUMN [name-of-column] VARCHAR(120);`
    Adding a column: `ALTER TABLE [table] ADD COLUMN [column] VARCHAR(120);`

    Adding a column with an unique, auto-incrementing ID: `ALTER TABLE [name-of-table] ADD COLUMN [name-of-column] int NOT NULL AUTO_INCREMENT PRIMARY KEY;`
    Adding a column with an unique, auto-incrementing ID: `ALTER TABLE [table] ADD COLUMN [column] int NOT NULL AUTO_INCREMENT PRIMARY KEY;`

    Inserting a record: `INSERT INTO [name-of-table] ([name-of-column], [name-of-column]) VALUES ('[custom-input]', [custom-input]');`
    Inserting a record: `INSERT INTO [table] ([column], [column]) VALUES ('[value]', [value]');`

    MySQL function for datetime input: `NOW()`

    Selecting records: `SELECT * FROM [name-of-table];`
    Selecting records: `SELECT * FROM [table];`

    Selecting parts of records: `SELECT [name-of-column], [name-of-another-column] FROM [name-of-table];`
    Selecting parts of records: `SELECT [column], [another-column] FROM [table];`

    Counting records: `SELECT COUNT([name-of-column]) FROM [name-of-table];`
    Counting records: `SELECT COUNT([column]) FROM [table];`

    Counting and selecting grouped records: `SELECT *, (SELECT COUNT([name-of-column]) FROM [name-of-table]) AS count FROM [name-of-table] GROUP BY [name-of-column];`
    Counting and selecting grouped records: `SELECT *, (SELECT COUNT([column]) FROM [table]) AS count FROM [table] GROUP BY [column];`

    Selecting specific records: `SELECT * FROM [name-of-table] WHERE [name-of-column] = [custom-input];` (Selectors: `<`, `>`, `!=`)
    Selecting specific records: `SELECT * FROM [table] WHERE [column] = [value];` (Selectors: `<`, `>`, `!=`)

    Searching records for a word: `SELECT * FROM [name-of-table] WHERE [name-of-column] LIKE '%[custom-input]%';`
    Searching records for a word: `SELECT * FROM [table] WHERE [column] LIKE '%[value]%';`

    Searching records for a word starting with [custom-input]: `SELECT * FROM [name-of-table] WHERE [name-of-column] LIKE '[custom-input]%';`
    Searching records for a word starting with [value]: `SELECT * FROM [table] WHERE [column] LIKE '[value]%';`

    Updating records: `UPDATE [table] SET [column] = '[updated-value]' WHERE [column] = [value];`

    Deleting records: `DELETE FROM [table] WHERE [column] = [value];`

    Removing table columns: `ALTER TABLE [table] DROP COLUMN [column];`

    Deleting tables: `DROP TABLE [table];`

    Deleting databases: `DROP DATABASE [database];`

    Custom column output names: `SELECT [column] AS [custom-column] FROM [table];`

    Logout: `exit`
  11. @hofmannsven hofmannsven revised this gist Feb 23, 2014. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -35,4 +35,14 @@ Selecting records: `SELECT * FROM [name-of-table];`

    Selecting parts of records: `SELECT [name-of-column], [name-of-another-column] FROM [name-of-table];`

    Counting records: `SELECT COUNT([name-of-column]) FROM [name-of-table];`

    Counting and selecting grouped records: `SELECT *, (SELECT COUNT([name-of-column]) FROM [name-of-table]) AS count FROM [name-of-table] GROUP BY [name-of-column];`

    Selecting specific records: `SELECT * FROM [name-of-table] WHERE [name-of-column] = [custom-input];` (Selectors: `<`, `>`, `!=`)

    Searching records for a word: `SELECT * FROM [name-of-table] WHERE [name-of-column] LIKE '%[custom-input]%';`

    Searching records for a word starting with [custom-input]: `SELECT * FROM [name-of-table] WHERE [name-of-column] LIKE '[custom-input]%';`

    Logout: `exit`
  12. @hofmannsven hofmannsven revised this gist Feb 23, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@ Adding a column: `ALTER TABLE [name-of-table] ADD COLUMN [name-of-column] VARCHA

    Adding a column with an unique, auto-incrementing ID: `ALTER TABLE [name-of-table] ADD COLUMN [name-of-column] int NOT NULL AUTO_INCREMENT PRIMARY KEY;`

    Inserting a record: `INSERT INTO [name-of-table] ([name-of-column], [name-of-another-column]) VALUES ('[custom-input]', [custom-input]');`
    Inserting a record: `INSERT INTO [name-of-table] ([name-of-column], [name-of-column]) VALUES ('[custom-input]', [custom-input]');`

    MySQL function for datetime input: `NOW()`

  13. @hofmannsven hofmannsven revised this gist Feb 23, 2014. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -21,6 +21,18 @@ Show all tables: `show tables;`

    Show table structure: `describe [name-of-table];`

    Create tables and columns: `CREATE TABLE [name-of-table] ([name-of-column] VARCHAR(120), [name-of-another-column] DATETIME);`
    Create new table with columns: `CREATE TABLE [name-of-table] ([name-of-column] VARCHAR(120), [name-of-another-column] DATETIME);`

    Adding a column: `ALTER TABLE [name-of-table] ADD COLUMN [name-of-column] VARCHAR(120);`

    Adding a column with an unique, auto-incrementing ID: `ALTER TABLE [name-of-table] ADD COLUMN [name-of-column] int NOT NULL AUTO_INCREMENT PRIMARY KEY;`

    Inserting a record: `INSERT INTO [name-of-table] ([name-of-column], [name-of-another-column]) VALUES ('[custom-input]', [custom-input]');`

    MySQL function for datetime input: `NOW()`

    Selecting records: `SELECT * FROM [name-of-table];`

    Selecting parts of records: `SELECT [name-of-column], [name-of-another-column] FROM [name-of-table];`

    Logout: `exit`
  14. @hofmannsven hofmannsven created this gist Feb 23, 2014.
    26 changes: 26 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    MySQL Command Line Interface
    ===============

    Related tutorial: http://cd64.de/mysql-cli


    Commands
    -----------

    Access monitor: `mysql -u [username] -p` (will prompt for password)

    Show all databases: `show databases;`

    Access database: `mysql -u [username] -p [name-of-database]` (will prompt for password)

    Create new database: `create database [name-of-database];`

    Select database: `use [name-of-database];`

    Show all tables: `show tables;`

    Show table structure: `describe [name-of-table];`

    Create tables and columns: `CREATE TABLE [name-of-table] ([name-of-column] VARCHAR(120), [name-of-another-column] DATETIME);`

    Logout: `exit`
    1 change: 1 addition & 0 deletions bash_profile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    alias mysql=/Applications/MAMP/Library/bin/mysql