查看當前使用的數據庫,可使用如下命令
#查詢數據庫中所有表名
mysql> select table_name from information_schema.tables where table_schema='mysql' and table_type='base table';
#查詢指定數據庫中指定表的所有字段名column_name
mysql> select column_name from information_schema.columns where table_schema='mysql' and table_name='users'
mysql> select database(); #使用函數database()
mysql> show tables; #列頭信息中可看出當前使用的db,格式為:Tables_in_[db_name]
mysql> status; #注意結果中的"Current database:"信息
查看系統中有哪些數據庫,
mysql> show databases;
更換當前使用的數據庫,
mysql> use db_name;
返回當前數據庫下的所有表的名...詳情