Loading...
Archive for the ‘Oracle RDBMS’ Category
  1. 昨天上night shif,不小心弄错了数据库环境,覆盖了三个procedure过程和一个package,导致应用出了问题。
    其实今天晚上比较忙,事情比较多,但越是在这种情况下,出错的可能性就越大,越要保持清醒的头脑。
    出了事情,心理很不爽,就好像吃饭吃到了苍蝇一样。
    为了避免这样的情况再次发生,计划形成一套适合自己的工作方法。
    先记录以下几点:
    1.稳字当先
    2.工作窗口不要打开太多
    3.如果有类似的任务,一定不要考虑并行
    4.出了事不要尝试自己去恢复,一定要让leader知道

    Popularity: 35% [?]

  2. By Jeff Hunter, ideveleopment.info
    Script:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    
    REM +-----------------------------------------------------------------+
    REM | FILE    : user_transaction_information.sql                      |
    REM | AUTHOR  : Jeff Hunter                                           |
    REM | PURPOSE : List TABLE locking AND user transactions information. | 
    REM +-----------------------------------------------------------------+
     
    SET LINESIZE 145
    SET PAGESIZE 66
     
    COLUMN owner        FORMAT a5      HEADING 'Owner'
    COLUMN object_type  FORMAT a10     HEADING 'Type'
    COLUMN object_name  FORMAT a25     HEADING 'Name'
    COLUMN locked_mode  FORMAT a9      HEADING 'Locked Mode'
    COLUMN sid          FORMAT 999     HEADING 'SID'
    COLUMN username     FORMAT a15     HEADING 'Database User'
    COLUMN osuser       FORMAT a10     HEADING 'O/S User'
    COLUMN logon_time                  HEADING 'Login Time'
     
    Prompt +----------------------------------------------------+
    Prompt | TABLE Locking Information                          |
    Prompt +----------------------------------------------------+
     
    SELECT
        SUBSTR(b.owner, 1, 8)           owner
      , b.object_type                   object_type
      , SUBSTR(b.object_name, 1, 18)    object_name
      , DECODE(a.locked_mode
                 , 0, 'None'
                 , 1, 'Null'
                 , 2, 'Row-S'
                 , 3, 'Row-X'
                 , 4, 'Share'
                 , 5, 'S/Row-X'
                 , 6, 'Exclusive')      locked_mode
      , a.session_id                    sid
      ,a.oracle_username                username
      , a.os_user_name                  osuser
      , TO_CHAR(c.logon_time,'YYYY/MM/DD HH24:MI:SS') logon_time
    FROM
        v$locked_object a
      , dba_objects b
      , v$session c
    WHERE
          a.object_id  = b.object_id
      AND a.session_id = c.sid
    ORDER BY
        b.owner
      , b.object_type
      , b.object_name
    /
     
    Prompt +----------------------------------------------------+
    Prompt | User Transactions Information                      |
    Prompt +----------------------------------------------------+
     
    COLUMN "UserName" format a8
    COLUMN "DB Sid" format 999999
    COLUMN "Unix Pid" format 99999999
    COLUMN "Trnx_start_time" format a19
    COLUMN "Current Time" format a19
    COLUMN "Elapsed(mins)" format 999999999.99
    COLUMN "Undo Name" format a09
    COLUMN "Used Undo Blks" format a13
    COLUMN "Used Undo Size(Kb)" format a17
    COLUMN "Logical I/O(Blks)" format 99999999999999999
    COLUMN "Logical I/O(Kb)" format 999999999999999
    COLUMN "Physical I/O(Blks)" format 999999999999999999
    COLUMN "Physical I/O(Kb)" format 999999999999999999
     
    SELECT
        a.username  "UserName"
      , a.sid       "DB Sid"
      , e.spid      "Unix Pid"
      , TO_CHAR(TO_DATE(b.start_time,'mm/dd/yy hh24:mi:ss'),'yyyy/mm/dd hh24:mi:ss') "Trnx_start_time"
      , TO_CHAR(sysdate,'yyyy/mm/dd hh24:mi:ss') "Current Time"
      , ROUND(60*24*(sysdate-to_date(b.start_time,'mm/dd/yy hh24:mi:ss')),2) "Elapsed(mins)"
      , c.segment_name "Undo Name"
      , TO_CHAR(b.used_ublk*d.value/1024) "Used Undo Size(Kb)"
      , TO_CHAR(b.used_ublk) "Used Undo Blks"
      , b.log_io "Logical I/O(Blks)"
      , b.log_io*d.value/1024 "Logical I/O(Kb)"
      , b.phy_io "Physical I/O(Blks)"
      , b.phy_io*d.value/1024 "Physical I/O(Kb)"
      , a.program 
    FROM
        v$session         a
      , v$transaction     b
      , dba_rollback_segs c
      , v$parameter       d
      , v$process         e
    WHERE
          b.ses_addr = a.saddr
      AND b.xidusn   = c.segment_id
      AND d.name     = 'db_block_size'
      AND e.ADDR     = a.PADDR
    ORDER BY 4
    /

    Note:
    In addition to an explicit LOCK SQL command run on the table (as Jonathan pointed out), another possibility of having a lock without a transaction is a DML with a long-running query as its prerequisite, such as
    INSERT INTO YOURTABLE SELECT COLUMNS FROM SOMEBIGTABLE This immediately creates a TM lock in mode 3 on YOURTABLE, but won’t create a transaction until the query phase is finished.
    When you have this problem, check v$sql.sql_text for the locking session and also its entry in v$session_wait.

    Popularity: 21% [?]

  3. 1.Creating Tablespace

    CREATE TABLESPACE tablespace
    [DATAFILE clause]
    [MINIUM EXTENT integer[K|M]]
    [BLOCKSIZE integger [K]]
    [LOGGING|NOLOGGING]
    [DEFAULT storage_clause]
    [ONLINE|OFFLINE]
    [PERMANENT|TEMPORARY]

    More…

    Popularity: 21% [?]

  4. 1.Your database is running under automatic undo management and the UNDO_RETENTION parameter is set to 900 sec.
    You executed the following command to enable retention guarantee:
    ALTER TABLESPACE undotbs1 RETENTION GUARANTEE
    What efeect would this statement have on the database?
    A - The extents in undo tablespace retain data until the next full database backup.
    B - The extents containing committed data in the undo tablespace are never overwritten.
    C - The extents which no longer contain uncommitted data in the undo tablespace
    are not overwritten for at least 15 minutes.
    D - The extents containing committed data in the undo tablespace are not overwritten
    until the instance is shut down.

    More…

    Popularity: 38% [?]

  5. 1.Which three statements are true regarding the logical structure of the Oracle database?(choose three)
    A - Each segment contains one or more extents
    B - Mutiple tablespaces can share single datafile
    C - A data block is a smallest unit of I/O for data files.
    D - it is possible to have tablespaces of different blocks size in a database
    E - Each data block in the database always corresponds to one OS block.
    (Answer:A,C,D)

      More…

    Popularity: 35% [?]

Powered by ExtJS Theme flavored Wordpress.