数据库选定,数据库选定后依然可以使用其他数据库中的数据表,只要指定【数据库.数据表】即可
use db_name
select * from db_name.tbl_name
显示所有数据库
mysql> select schema_name from information_schema.schemata;
+--------------------+
| schema_name |
+--------------------+
| information_schema |
| feng |
| mysql |
+--------------------+
3 rows in set (0.11 sec)
显示属于数据库feng的表
mysql> select table_name from information_schema.tables where table_schema='feng';
+------------+
| table_name |
+------------+
| feng |
+------------+
1 row in set (0.05 sec)
数据库创建
create database db_name
create database db_name if not exists db_name
create database db_name if not exists db_name character set utf8 collate utf8_icelandic_ci
show create database db_name\G
数据库删除
drop database db_name
drop database db_name if not exists db_name
数据库修改
alter database db_name default character set utf8
default collate utf8_general_ci