mysql
MySQL / MariaDB
Formatting output
Truncate long fields for easier display
mysql> SELECT SUBSTRING(myfield,0,15) FROM tablenamemysql> SELECT SUBSTRING(myfield,10) FROM tablenameShow epochtime in human readable format
mysql> SELECT from_unixtime(fieldname) FROM tablenameFormat output in 1 field per line
mysql> $query \G;Use a pager with multi-screen results
Common actions
See warnings when an update/delete/insert reports warnings
Run commands in a flatfile (ex: output of mysqldump)
Run single command and output results (without formatting)
See what processes and queries are running
Creating a user
Examples:
Empty out a table
Foreign Keys
Requirements
Adding foreign keys
ORDER BY/GROUP BY/HAVING
Example
Last updated