查询数据库中某张用户表的列数(Oracle和Mysql)Sql

Oracle和MySql数据库区别之__查询数据库中某张用户表的列数

查询Oracle数据库中某张用户表的列数(需要查询的表名必须大写)

select count(*) from user_tab_columns t where t.table_name = '表名'
  1. 大写表名查询成功这里写图片描述
  2. 小写表名查询失败002
  3. ORA-00942错误(informatin_schema.COLUMNS表不存在)003

查询Mysql数据库中某张用户表的列数

select count(*) from informatin_schema.COLUMNS where table_schema = '数据库名' and table_name= '表名'
  1. sql错误: user_tab_columns表不存在004
  2. 已经指定对应的数据库下查询,sql就不需要指定 table_schema = ‘数据库名’ 005

如果要查询具体的列信息,select count(*) from 换成select * from 即可,Oracle和MySql数据库都支持

猜你喜欢

转载自blog.csdn.net/Sqiuyang/article/details/80762699