码迷,mamicode.com
首页 > 数据库 > 详细

mysql中获取表名&字段的查询语句

时间:2018-12-01 18:37:38      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:系统   名称   ase   for   info   tab   style   type   数据库   

  1:查询数据库中所有表名
  select table_name

  from information_schema.tables

  where table_schema=‘csdb‘ and table_type=‘base table‘;

  table_schema:用于限定数据库名称,此处我用了自建的csdb库,你查用你的,注意:information_schema表示系统库。

  table_type=‘base table‘:限定只查询基表。

  2:查询指定数据库中指定表的所有字段名column_name
   select column_name

     from information_schema.columns

     where table_schema=‘csdb‘ and table_name=‘users‘;

  table_schema:用于限定数据库名。

  table_name:用于限定表名。

注意:若查询报1064错误,说明你的某个标点符号有问题

mysql中获取表名&字段的查询语句

标签:系统   名称   ase   for   info   tab   style   type   数据库   

原文地址:https://www.cnblogs.com/zja001/p/10050246.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!