在命令行里面,可以直接通过
show databases;
和show tables;
以及desc sys_user
来查看表,但是在程序中,不能直接通过这种方法来获取,解决办法如下
通过sql语句查看表和列信息
-- 登录yellowcong 数据库
mysql -uroot -proot yellowcong
-- 查看当前数据库
select database()
-- 查看数据库里面的表
--table_schema 当前的数据库
--table_type='base table' 表示基础的普通表
SELECT table_name FROM information_schema.tables WHERE table_schema='yellowcong' AND table_type='base table';
-- 查询指定数据库中指定表的所有字段名column_name
-- 查看列的名称
SELECT column_name FROM information_schema.columns WHERE table_schema='yellowcong' AND table_name='sys_user';
登录,并查看当前数据库
查看当前数据据库额表
查看表sys_user的列名称
命令查看
-- 查看数据库
show databases;
-- 模糊查询包含y的数据库
show databases like '%y%';
-- 查看表
show tables;
--模糊查询包含user的表
show tables like '%user%';
-- 查看列, 查看sys_user表信息
desc sys_user;
查看数据库
查看表
查看某张表信息
库和表的模糊查询