Table of Contents
SQL Commands
Document some SQL commands.
Database
Statements
Table 1. Statements to access database
show databases [like 'pattern'] | List all databases. |
use database | Select the database to interact with. |
show tables [like 'pattern'] | Lists all tables in the currently selected database. |
In the above commands,
%
is used as a wildcard in the pattern.
Demo
show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| stats |
| sys |
+--------------------+
5 rows in set (0.001 sec)
show databases like '%sql%';
+------------------+
| Database (%sql%) |
+------------------+
| mysql |
+------------------+
1 row in set (0.001 sec)
use mysql
Database changed
show tables like 'column%';
+---------------------------+
| Tables_in_mysql (column%) |
+---------------------------+
| column_stats |
| columns_priv |
+---------------------------+
2 rows in set (0.001 sec)
Table
Statements
Table 2. Statements to access table
Statement | Description |
---|---|
delete from table where condition | Delete the specified rows. |
show columns from table | Lists information about the columns in specified table. |