5.笔记 MySQL学习——mysql基本显示查询

5.笔记 MySQL学习——mysql基本显示查询

1.  显示数据库

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sampdb             |

| sys                |

+--------------------+

5 rows in set (0.06 sec)

也可以直接如下执行:

 [root@OEL ~]#mysqlshow -u root -p

Enter password:

+--------------------+

|    Databases      |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sampdb             |

| sys                |

+--------------------+

选择数据库

mysql> use sampdb

2.  查看表中列

mysql> show columns from president like'%name';

+------------+-------------+------+-----+---------+-------+

| Field     | Type        | Null | Key |Default | Extra |

+------------+-------------+------+-----+---------+-------+

| last_name | varchar(15) | NO   |     | NULL   |       |

| first_name | varchar(15) | NO   |    | NULL    |       |

+------------+-------------+------+-----+---------+-------+

2 rows in set (0.00 sec)

3.  显示表

mysql> show tables;

+------------------+

| Tables_in_sampdb |

+------------------+

| member           |

| president        |

+------------------+

2 rows in set (0.00 sec)

也可以如下:

[root@OEL ~]# mysqlshow sampdb -u root -p

Enter password:

Database: sampdb

+-----------+

| Tables   |

+-----------+

| member   |

| president |

+-----------+

 

 

 

 

 

 

 

你可能感兴趣的:(mysql,数据库)