• 【oracle sql】一行流取Oracle某表的字段名、注释和排序号


    【sql】

    select a.column_name as name,a.column_id as order_num,b.comments as remark
    from (select column_name,column_id from user_tab_columns where table_name=upper('test812')) a
    left join (select column_name,comments from user_col_comments where table_name=upper('test812')) b
    on a.column_name=b.column_name
    order by a.column_id

    【相对优势】

    用Metadata去取表字段信息,对oracle数据库稍有别扭,这种利用字典表的方法更简单快捷。

    【实验过程】

    1.建表并加注释

    create table test812(
        id number(12),
        name nvarchar2(20),
        title varchar2(20),
        primary key(id)
    );
    
    comment on table test812 is '测试表812';
    comment on column  test812.id  is '序列号';
    comment on column  test812.name is '名称';
    comment on column  test812.title is '职称';

    2.查询

    SQL> select a.column_name as name,a.column_id as order_num,b.comments as remark
      2  from (select column_name,column_id from user_tab_columns where table_name=upper('test812')) a
      3  left join (select column_name,comments from user_col_comments where table_name=upper('test812')) b
      4  on a.column_name=b.column_name
      5  order by a.column_id;
    
    NAME                  ORDER_NUM REMARK
    -------------------- ---------- --------------------
    ID                            1 序列号
    NAME                          2 名称
    TITLE                         3 职称

    END

  • 相关阅读:
    ios-表视图-demo4-内容自己适应高度
    ios-表视图-demo3-单选
    应用管理的实现
    初识MVC和KVC
    Xcode的常用快捷键
    UI基础--手写代码实现汤姆猫动画
    UI基础--UIView常见属性之frame、center、bounds、transframe属性
    UI基础--UIButton、懒加载
    ios多线程
    ios多线程简介
  • 原文地址:https://www.cnblogs.com/heyang78/p/16577701.html
Copyright © 2020-2023  润新知