• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
cnsdhzzl
博客园    首页    新随笔    联系   管理    订阅  订阅
Oracle,Mysql 获取用户下所有表名,获取表所有的列名及数据类型

Mysql


下面是mysql获取数据库所有表的语句
select table_name from information_schema.TABLES where TABLE_SCHEMA='Username'

information_schema这个是数据系统用来保存数据表的总表
select table_name tableName, engine, table_comment tableComment, create_time createTime from information_schema.tables where table_schema = (select database())
拿到表之后,可以获取表的所有字段。

select column_name columnName, data_type dataType, column_comment columnComment, column_key columnKey, extra from information_schema.columns
where table_name = 'tablename' and table_schema = (select database()) order by ordinal_position

 注:如果需要安装表设计顺序罗列,需要加  order by ordinal_position

 

Oracle


获取用户所有表
select table_name from user_tables where TABLESPACE_NAME is not null and  user='UserName' 

获取表字段 SELECT table_name, column_name, data_type FROM all_tab_cols WHERE table_name = 'tablename '
posted on 2018-10-25 11:01  cnsdhzzl  阅读(561)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3