本文作為note來記下如何查詢數據庫或表的名字,在MySQL中有幾個語句可以解決這個問題。
查看有哪些數據庫
show databases;
結果如下:
Database |
---|
information_schema |
mysql |
performance_schema |
test |
查看當前使用的是哪個數據庫
select database();
結果如下:
database() |
---|
test |
如果沒有選擇任何數據庫,則結果是Null。
選擇數據庫
use test;
查看當前數據庫有什么表
show tables;
看表里有哪些列
describe table_name;