sql语言以冒号结尾才能运行
查询所有收据库
show databases;
使用某个收据库
use databases-name;
两种方式对数据库进行使用的选择:
一: 在登录数据库时指定, 命令: mysql -D 所选择的数据库名 -h 主机名 -u 用户名 -p
例如登录时选择刚刚创建的数据库: mysql -D samp_db -u root -p
二: 在登录后使用 use 语句指定, 命令: use 数据库名;
use 语句可以不加分号, 执行 use samp_db 来选择刚刚创建的数据库, 选择成功后会提示: Database changed
查询数据库的所有表
select table_name from information_schema.tables where table_schema='database_name' and table_type='base table';
查看表的所有的内容
select * from student;
查看表的栏目
select column_name from information_schema.columns where table_schema='database_name' and table_name='table_name';