您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
小编给大家分享一下mysql怎样查询所有表和字段信息,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!
mysql查询所有表和字段信息的方法:1、根据库名获取所有表的信息【information_schema.`TABLES`】;2、根据库名获取所有的字段信息【ORDINAL_POSITION AS '列的排列顺序'】。
mysql查询所有表和字段信息的方法:
1、根据库名获取所有表的信息
SELECT * FROM information_schema.`TABLES` WHERE TABLE_SCHEMA = 'erp';
2、根据库名获取所有表名称和表说明
SELECT TABLE_NAME, TABLE_COMMENT FROM information_schema.`TABLES` WHERE TABLE_SCHEMA = 'erp';
view:
3、根据库名获取所有的字段信息
SELECT TABLE_SCHEMA AS '库名', TABLE_NAME AS '表名', COLUMN_NAME AS '列名', ORDINAL_POSITION AS '列的排列顺序', COLUMN_DEFAULT AS '默认值', IS_NULLABLE AS '是否为空', DATA_TYPE AS '数据类型', CHARACTER_MAXIMUM_LENGTH AS '字符最大长度', NUMERIC_PRECISION AS '数值精度(最大位数)', NUMERIC_SCALE AS '小数精度', COLUMN_TYPE AS 列类型, COLUMN_KEY 'KEY', EXTRA AS '额外说明', COLUMN_COMMENT AS '注释' FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = 'erp' ORDER BY TABLE_NAME, ORDINAL_POSITION;
view:
4、根据库名获取所有的库和表字段的基本信息
SELECT C.TABLE_SCHEMA AS '库名', T.TABLE_NAME AS '表名', T.TABLE_COMMENT AS '表注释', C.COLUMN_NAME AS '列名', C.COLUMN_COMMENT AS '列注释', C.ORDINAL_POSITION AS '列的排列顺序', C.COLUMN_DEFAULT AS '默认值', C.IS_NULLABLE AS '是否为空', C.DATA_TYPE AS '数据类型', C.CHARACTER_MAXIMUM_LENGTH AS '字符最大长度', C.NUMERIC_PRECISION AS '数值精度(最大位数)', C.NUMERIC_SCALE AS '小数精度', C.COLUMN_TYPE AS 列类型, C.COLUMN_KEY 'KEY', C.EXTRA AS '额外说明' FROM information_schema.`TABLES` T LEFT JOIN information_schema.`COLUMNS` C ON T.TABLE_NAME = C.TABLE_NAME AND T.TABLE_SCHEMA = C.TABLE_SCHEMA WHERE T.TABLE_SCHEMA = 'erp' ORDER BY C.TABLE_NAME, C.ORDINAL_POSITION;
view:
看完了这篇文章,相信你对mysql怎样查询所有表和字段信息有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。