项目实践中,被测系统无任何数据库表字段文档沉淀,开发日常事务比较多。这时候需要进行数据库的校验,就需要了解数据库对应表字段信息。除了通过数据库字典文档来了解数据库外,我们作为一名测试,也可以通过查询数据库的表以及表字段来了解,获取我们需要的信息。表名和字段名一般都会有对应的意义,不认识的可以通过有道翻译。
查询数据库中的所有表:
show tables or show full tables 表格形式列出mysql数据库中的所有表
查询指定数据库的所有表名,表描述,表行数:
select table_name,table_comment,table_rows from information_schema.tables where table_schema='pick';
information_schema
information_schema 有哪些数据库、各个数据库有哪些表,每张表的字段类型是什么,各个数据库要什么权限才能访问,等等信息都保存在information_schema表里面。
查询指定数据库指定表的所有列字段名,列字段描述:
select column_name,column_comment from information_schema.columns where table_schema='pick' and table_name='batch_order';
查询指定数据库指定表的所有信息:
select * from information_schema.columns where table_schema='pick' and table_name='batch_order';
table_schema 库名
table_name 表名