zoukankan      html  css  js  c++  java
  • Oracle 常用的查询操作

    –1. 查询系统所有对象
    select owner, object_name, object_type, created, last_ddl_time, timestamp, status
    from dba_objects
    where owner=upper('scott')

    –2. 查看系统所有表
    select owner, table_name, tablespace_name from dba_tables

    –3. 查看所有用户的表
    select owner, table_name, tablespace_name from all_tables

    –4. 查看当前用户表
    select table_name, tablespace_name from user_tables

    –5. 查看用户表索引
    select t.*,i.index_type from user_ind_columns t, user_indexes i where
    t.index_name = i.index_name and t.table_name = i.table_name
    and t.table_name = 要查询的表

    –6. 查看主键
    select cu.* from user_cons_columns cu, user_constraints au
    where cu.constraint_name = au.constraint_name
    and au.constraint_type = upper('p') and au.table_name = 要查询的表

    –7. 查看唯一性约束
    select column_name from user_cons_columns cu, user_constraints au
    where cu.constraint_name = au.constraint_name and au.constraint_type =  upper('u')
    and au.table_name = 要查询的表

    –8. 查看外键
    select * from user_constraints c where c.constraint_type = 'r' and c.table_name = 要查询的表
    select * from user_cons_columns cl where cl.constraint_name = 外键名称
    select * from user_cons_columns cl where cl.constraint_name = 外键引用表的键名

    –9. 查看表的列属性
    select t.*,c.comments
    from user_tab_columns t, user_col_comments c
    where t.table_name = c.table_name and t.column_name = c.column_name and t.table_name = 要查询的表

    –10. 查看所有表空间
    select tablespace_name from dba_data_files group by tablespace_name

    –11. 查看oracle最大连接数
    sql>show parameter processes    #最大连接数

    –12. 修改最大连接数
    sql>alter system set processes=value scope=spfile
    –重启数据库
    sql>shutdown force
    sql>start force

    –13. 查看当前连接数
    sql>select * from v$session where username is not null

    –14. 查看不同用户的连接数
    sql>select username,count(username) from v$session where username is not null group by username #查看指定用户的连接数

    –15. 查看活动的连接数
    sql>select count(*) from v$session where status='active' #查看并发连接数

    –16. 查看指定程序的连接数
    sql>select count(*) from v$session where program='jdbc thin client' #查看jdbc连接oracle的数目

    –17. 查看数据库安装实例(dba权限)
    sql>select * from v$instance

    –18. 查看运行实例名
    sql>show parameter instance_name

    –19. 查看数据库名
    sql>show parameter db_name

    –20. 查看数据库域名
    sql>show parameter db_domain

    –21. 查看数据库服务名
    sql>show parameter service_names

    –22. 查看全局数据库名
    sql>show parameter global

    –23. 查看表空间使用率

     1 -- (1)
     2 select dbf.tablespace_name,
     3        dbf.totalspace "总量(m)",
     4        dbf.totalblocks as "总块数",
     5        dfs.freespace "剩余总量(m)",
     6        dfs.freeblocks "剩余块数",
     7        (dfs.freespace / dbf.totalspace) * 100 as "空闲比例"
     8   from (select t.tablespace_name,
     9                sum(t.bytes) / 1024 / 1024 totalspace,
    10                sum(t.blocks) totalblocks
    11           from dba_data_files t
    12          group by t.tablespace_name) dbf,
    13        (select tt.tablespace_name,
    14                sum(tt.bytes) / 1024 / 1024 freespace,
    15                sum(tt.blocks) freeblocks
    16           from dba_free_space tt
    17          group by tt.tablespace_name) dfs
    18  where trim(dbf.tablespace_name) = trim(dfs.tablespace_name)
    19 -- (2)
    20 select t.name "tablespace name",
    21        free_space,
    22        (total_space - free_space) used_space,
    23        total_space
    24   from (select tablespace_name, sum(bytes / 1024 / 1024) free_space
    25           from sys.dba_free_space
    26          group by tablespace_name) free,
    27        (select b.name, sum(bytes / 1024 / 1024) total_space
    28           from sys.v_$datafile a, sys.v_$tablespace b
    29          where a.ts# = b.ts#
    30          group by b.name) t
    31  where free.tablespace_name = t.name
  • 相关阅读:
    fiyocms 2.0.6.1版本漏洞复现及分析
    WPScan使用方法
    sqlmap的使用方法(含靶场)
    COOKIE注入靶场实战
    LDAP注入学习小记
    XSS挑战赛通关
    LANMP安全配置之Nginx安全配置
    LANMP安全配置之MySQL安全配置
    LANMP安全配置之Apache安全配置
    open-source
  • 原文地址:https://www.cnblogs.com/xiaoxiaoweng/p/7454028.html
Copyright © 2011-2022 走看看