ITPub博客

首页 > 数据库 > Oracle > [20230302]建立完善tpt o2.sql脚本.txt

[20230302]建立完善tpt o2.sql脚本.txt

原创 Oracle 作者:lfree 时间:2023-03-03 08:45:11 0 删除 编辑

[20230302]建立完善tpt o2.sql脚本.txt

--//发现该脚本显示没有分区名,顺便加上,这样结合seg2.sql的执行,显示更加直观一些。

$ cat o2.sql
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.

col o_owner heading owner for a25
col o_object_name heading object_name for a30
col o_object_type heading object_type for a20
col o_status heading status for a9

select
    owner o_owner,
    object_name o_object_name,
    object_type o_object_type,
    subobject_name seg_part_name,
    status o_status,
    object_id oid,
    data_object_id d_oid,
    created,
    last_ddl_time
from
    dba_objects
where
        upper(object_name) LIKE
                                upper(CASE
                                        WHEN INSTR('&1','.') > 0 THEN
                                            SUBSTR('&1',INSTR('&1','.')+1)
                                        ELSE
                                            '&1'
                                        END
                                     )
AND     owner LIKE
                CASE WHEN INSTR('&1','.') > 0 THEN
                        UPPER(SUBSTR('&1',1,INSTR('&1','.')-1))
                ELSE
                        user
                END
order by
    o_object_name,
    o_owner,
    o_object_type
/

--//测试例子:
SYS@192.168.100.141:1521/dyhis> @ pr
==============================
PORT_STRING                   : x86_64/Linux 2.4.xx
VERSION                       : 19.0.0.0.0
BANNER                        : Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
BANNER_FULL                   : Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.9.0.0.0
BANNER_LEGACY                 : Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
CON_ID                        : 0
PL/SQL procedure successfully completed.

SYS@192.168.100.141:1521/dyhis> @ seg2 audsys.AUD$UNIFIED
SEG_MB OWNER  SEGMENT_NAME SEG_PART_NAME SEGMENT_TYPE    SEG_TABLESPACE_NAME BLOCKS HDRFIL HDRBLK
------ ------ ------------ ------------- --------------- ------------------- ------ ------ ------
    10 AUDSYS AUD$UNIFIED  SYS_P20923    TABLE PARTITION SYSAUX                1280      3 145690
   144 AUDSYS AUD$UNIFIED  SYS_P19622    TABLE PARTITION SYSAUX               18432      3 656234
    88 AUDSYS AUD$UNIFIED  SYS_P20283    TABLE PARTITION SYSAUX               11264      3 550906

SYS@192.168.100.141:1521/dyhis> @ o2 audsys.AUD$UNIFIED
owner  object_name object_type     SEG_PART_NAME status     OID  D_OID CREATED             LAST_DDL_TIME
------ ----------- --------------- ------------- ------ ------- ------ ------------------- -------------------
AUDSYS AUD$UNIFIED TABLE                         VALID    18580        2020-10-20 10:28:13 2023-03-01 11:21:46
AUDSYS AUD$UNIFIED TABLE PARTITION SYS_P20283    VALID   174234 174234 2023-02-01 08:00:00 2023-02-01 08:00:00
AUDSYS AUD$UNIFIED TABLE PARTITION SYS_P20923    VALID   176513 176513 2023-03-01 08:00:05 2023-03-01 08:00:05
AUDSYS AUD$UNIFIED TABLE PARTITION SYS_P19622    VALID   171804 171804 2023-01-01 08:00:04 2023-01-01 08:00:04


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2937971/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7970277