SQL> SELECT STARTUP_TIME FROM dba_hist_database_instance ORDER BY startup_time DESC;
STARTUP_TIME
---------------------------------------------------------------------------
12-JUL-21 09.10.09.000 AM
16-APR-21 07.53.43.000 AM
16-APR-21 07.53.43.000 AM
12-JAN-20 12.36.43.000 AM
12-JAN-20 12.30.40.000 AM
12-JAN-20 12.28.10.000 AM
12-JAN-20 12.23.46.000 AM
12-JAN-20 12.13.55.000 AM
Monday, 20 September 2021
historical information of Oracle Instance startup time
Move SQL Profiles from One Database to Another
SQL Profile is a collection of information stored in the data dictionary that enables the query optimizer to create an optimal execution plan for a SQL statement.The SQL profile contains corrections for poor optimizer estimates discovered during Automatic SQL Tuning. This information can improve optimizer cardinality and selectivity estimates, which in turn leads the optimizer to select better plans..
Steps to copy profile from one DB to Another:
1.Creating a staging table to store the SQL Profiles
EXEC DBMS_SQLTUNE.CREATE_STGTAB_SQLPROF(table_name=>'SQLPROFILE_STAGE_TABLE',schema_name=>'SCOTT');
PL/SQL procedure successfully completed.
2.Pack the SQL Profiles into the Staging Table
EXEC DBMS_SQLTUNE.PACK_STGTAB_SQLPROF (profile_category => '%',staging_table_name =>'SQLPROFILE_STAGE_TABLE',staging_schema_owner=>'SCOTT');
PL/SQL procedure successfully completed.
3. Take backup of staging table and copy dump to target db host
expdp username/password dumpfile=EXPDP_SqlProfiles.dmp logfile=EXPDP_SqlProfiles.log DIRECTORY=ORACLE_BASE
4.Import staging table on target db
impdp username/password dumpfile=EXPDP_SqlProfiles.dmp logfile=IMPDP_SqlProfiles.log DIRECTORY=ORACLE_BASE
5.Unpack Staging Table
If importing to the same schema, schema owner does not need to be specified:
SQL> EXEC DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF(replace => TRUE,staging_table_name => 'SQLPROFILE_STAGE_TABLE');
However, if importing to different schema, the staging schema owner needs to be changed:|
SQL> EXEC DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF(replace => TRUE,staging_table_name => 'SQLPROFILE_STAGE_TABLE',staging_schema_owner => 'SCOTT');
PL/SQL procedure successfully completed.
6.Validate profiles on target side
select * from from DBA_SQL_PROFILES;
Find Rollback transaction in oracle
Rollback transaction Status:
select usn, state, undoblockstotal "Total", undoblocksdone "Done", undoblockstotal-undoblocksdone "ToDo",
decode(cputime,0,'unknown',sysdate+(((undoblockstotal-undoblocksdone) / (undoblocksdone / cputime)) / 86400)) "Estimated time to complete"
from v$fast_start_transactions;
Find rollback session details:
select s.sid, s.username, t.xidusn, t.used_urec, t.used_ublk
from gv$session s, gv$transaction t
where s.saddr=t.ses_addr
order by 2;
How Computers Understand IPv4 Addresses
IPv4 in Different Formats
What Humans See vs What Computers See
Human Format (Dotted Decimal): 192.168.1.1
Computer Format (32-bit Binary): 11000000.10101000.00000001.00000001
Computer Format (Single Decimal): 3232235777
Step-by-Step Conversion Example
Let's take the IP address 192.168.1.1 and see how a computer processes it:
Step 1: Convert Each Octet to Binary
192 = 11000000
168 = 10101000
1 = 00000001
1 = 00000001
Step 2: How to Convert Decimal to Binary
Let's break down 192:
192 ÷ 2 = 96 remainder 0
96 ÷ 2 = 48 remainder 0
48 ÷ 2 = 24 remainder 0
24 ÷ 2 = 12 remainder 0
12 ÷ 2 = 6 remainder 0
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1
Reading upward: 11000000
Step 3: Computer's Internal Representation
The computer sees the entire IP as one 32-bit number:
11000000 10101000 00000001 00000001
Step 4: Converting to Single Decimal Number
To get the decimal equivalent:
Binary: 11000000101010000000000100000001
Decimal: 3,232,235,777
More Examples
Example 1: Google's DNS 8.8.8.8
Human: 8.8.8.8
Binary: 00001000.00001000.00001000.00001000
Single Decimal: 134,744,072
Conversion of 8 to binary:
8 ÷ 2 = 4 remainder 0
4 ÷ 2 = 2 remainder 0
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1
Result: 00001000
Example 2: Localhost 127.0.0.1
Human: 127.0.0.1
Binary: 01111111.00000000.00000000.00000001
Single Decimal: 2,130,706,433
### Behind the Scenes: How Your Computer Uses This
Here's what happens when you type `ping 192.168.1.1`:
1. Parse: Computer splits "192.168.1.1" into [192, 168, 1, 1]
2. Convert: Each number becomes 8-bit binary
3. Combine: Creates the 32-bit address `11000000101010000000000100000001`
4. Process: Uses binary operations for routing decisions
### Network Calculations Made Simple
Your computer uses these binary representations for lightning-fast network calculations:
Your IP: 192.168.1.100 → 11000000.10101000.00000001.01100100
Subnet Mask: 255.255.255.0 → 11111111.11111111.11111111.00000000
Network: 192.168.1.0 → 11000000.10101000.00000001.00000000
This binary math helps your router instantly determine whether to send data locally or to the next hop on the internet.
Delete the last 10 files in a directory in Linux
To delete the last 10 files in a directory using a command in Linux, you can use a combination of ls
, tail
, xargs
, and rm
.
ls -ltr | tail -n 10 | awk '{print $9}' | xargs rm
ls -ltr: Lists files in long format (-l), sorted by modification time, with the newest files last (-t), and in reverse order (-r).
tail -n 10: Selects the last 10 lines from the ls output. Note that tail -n 9 would give you only 9 files; -n 10 ensures you are selecting the last 10 files.
awk '{print $9}': Extracts the filenames from the ls output. This assumes filenames are in the 9th column. This might need adjustments based on the actual output format, especially if filenames have spaces.
xargs rm: Passes the extracted filenames to rm for deletion.