美文网首页
oracle数据库表信息查询操作

oracle数据库表信息查询操作

作者: 洛奇lodge | 来源:发表于2018-11-03 23:56 被阅读0次
    随机获取oracle数据库数据量
      // 从全表数据随机抽取10%,获取前10条数据
      select * from 表名 sample(10) where rownum > 10;
    
    查看oracle数据库的所有表
      select * from user_tables
    
    查看某个表的字段和类型,默认值,字段注释
     select 
       a.column_name,
       a.data_type,a.data_length,a.nullable,
       a.data_default,
       b.comments 
     from 
        user_tab_columns a,
        user_col_comments b 
     where 
        a.table_name = b.table_name 
     and 
        a.column_name = b.column_name 
     and 
        a.table_name = '表名'(表名要大写)
    
    查看某个表的主键
     select
       b.column_name
     from
       user_constraints a,
       user_cons_columns b
     where
       a.constraint_name=b.constraint_name 
     and 
       a.constraint_type='P'
     and 
        b.table_name='表名'(表名要大写)
    
    查看某个表的外键
     select * from user_constraints where constraint_type='R' and table_name = '表名'(表名要大写)
    
    查看某个表的前几行数据,在oracle没有limit操作
     select * from 表名 where rownum < 行数;

    相关文章

      网友评论

          本文标题:oracle数据库表信息查询操作

          本文链接:https://www.haomeiwen.com/subject/iqilxqtx.html