Database CLI
Jump to navigation
Jump to search
This page contains some helpful commands to use at the MariaDB CLI.
>SHOW DATABASES;
List all databases;>USE <database>;
Use a particular database, eg:>USE bplan;
>SHOW TABLES;
List all tables in a database (after using USE);>DESCRIBE <name of table>;
Prints the structure of a table, eg:DESCRIBE tbl_entity;
>SELECT * FROM <name of table>;
Prints all records from the named table, eg:SELECT * FROM tbl_entity;
>SELECT * FROM <name of table> WHERE <condition>;
Prints all records from the named table where the condition is met, eg:SELECT * FROM tbl_entity WHERE td LIKE "CE";
>SELECT <columns> FROM <name of table> WHERE <condition>;
Prints named columns from the named table where the condition is met, eg.SELECT td, berth FROM approach_berth WHERE dockers = "Crewe_Station";
>SELECT COUNT(*) FROM <name of table>;
Prints a count of table records for the named table.>SELECT COUNT(*) FROM <name of table> WHERE <condition>;
Prints a count of table records for the named table where the condition is met, eg.SELECT COUNT(*) FROM users WHERE email LIKE "%networkrail.co.uk%";