Hello! This is the official page of Wayne Sebastian Pereanu.

Software > Cheat Sheets > SQL

Dump a database
/usr/bin/mysqldump -u username -ppassword database_name > sql_file.sql
/usr/bin/mysqldump -u username -ppassword database_name table_name > sql_file_table.sql
/usr/bin/mysqldump -u username -ppassword database_name table_name --where="column_name='a_value'" > sql_file_table_queried.sql

Common SQL statements
SHOW databases; //List all databases
USE database;  //Switch to a database
CREATE database; //creates a new database
/usr/bin/mysql -u username -ppassword database_name < sql_file.sql //import a database
SHOW tables; //List all tables in current database
DESCRIBE table_name; //Get structure of a table
DROP TABLE table_name; //delete a table
SELECT COUNT(*) FROM table_name; //Get number of rows in a table

Get distinct entries in a column
SELECT DISTINCT column_name FROM table_name;