【问题标题】:How to list all the user tables in SQL Anywhere along with their rowcount?如何列出 SQL Anywhere 中的所有用户表及其行数?
【发布时间】:2013-11-08 18:15:59
【问题描述】:

我想列出我的数据库中所有可用的表,并能够按行数排序和过滤。

【问题讨论】:

    标签: sql sybase sqlanywhere


    【解决方案1】:

    这很简单:

    select table_name, count
    from systable
    where primary_root<>0 and creator=1
    order by 1
    

    或者如何添加列数和名称?

    select t.table_name, t.count rows, count(*) cols,
      list(c.column_name order by c.column_id) col_list
    from systable t
    left outer join syscolumn c on c.table_id=t.table_id
    where t.primary_root<>0 and t.creator=1
    group by t.table_name, t.count
    order by 1
    

    希望这会有所帮助...

    更多信息:从 SQL Anywhere 10 开始,systable 和 syscolumn 仅支持旧版向后兼容视图,而 Sybase 建议改用较新的系统表...因为我使用的是版本 9 和 11,所以我坚持使用这些。

    【讨论】:

    • 请注意,primary_root0 将不会列出任何没有主键的表,因此您可能会错过一些重要的表。
    猜你喜欢
    • 2013-08-14
    • 1970-01-01
    • 1970-01-01
    • 2017-02-21
    • 1970-01-01
    • 2015-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多