Atikh's DBA blog
  • Home
  • Oracle
  • MySQL
  • MongoDB
  • PostgreSQL
  • Snowflake
  • About Me
  • Contact Us

Know your Oracle database startup time in Days, Hours Minute

 Atikh Shaikh     oracle     No comments   

As a database administrator, we came across situation where we need to know the database startup time, We can fetch that using startup_time from v$instance

SQL> select to_char(startup_time,'DD-MM-YYY hh24:mm:ss') startup_time from v$instance;

STARTUP_TIME

------------------

03-09-023 22:09:04 

 

What if the application team or you want to know since how many days, how many hours, and how many minutes it was started, We have modified the query for that as well

 

SET LINES 200 PAGES 2000

COL INSTANCE_NAME FOR A15

COL “INSTANCE UP TIME” FOR A65

SELECT INSTANCE_NAME,

FLOOR(((SYSDATE-STARTUP_TIME)*24*60*60)/3600/24) || 'DAYS '

|| FLOOR ((FLOOR(((SYSDATE-STARTUP_TIME)*24*60*60)) –

FLOOR(((SYSDATE-STARTUP_TIME)*24*60*60)/3600/24)*24*60*60)/3600) || ' HOURS '

|| FLOOR(FLOOR ((FLOOR(((SYSDATE-STARTUP_TIME)*24*60*60))

– FLOOR(((SYSDATE-STARTUP_TIME)*24*60*60)/3600/24)*24*60*60) –

( FLOOR ((FLOOR(((SYSDATE-STARTUP_TIME)*24*60*60)) –

FLOOR(((SYSDATE-STARTUP_TIME)*24*60*60)/3600/24)*24*60*60)/3600))*60*60)/60) || ' MINUTES ' 

“INSTANCE UP TIME” FROM V$INSTANCE;

 

This query just plays around startup_time column of v$instance view. Below is the sample output. 


database-instance-uptime

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Instagram
  •  Pin
  •  linkedin
  •  reddit

ORA-12514: Cannot connect to database. Service FREE is not registered with the listener at host 127.0.0.1 port 1521

 Atikh Shaikh     oracle, Oracle23c     No comments   

I was getting the below error while starting up the Oracle 23c database, which is a new release from Oracle.

The same error was getting repeated while starting and shutting down. 

 

SQL> shu immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

ERROR:

ORA-12514: Cannot connect to database. Service FREE is not registered with the

listener at host 127.0.0.1 port 1521. (CONNECTION_ID=+wf/LAyCEVfgUwEAAH9uOg==)

Warning: You are no longer connected to ORACLE.

 

[oracle@localhost Desktop]$ sqlplus sys@free as sysdba

SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Sat May 6 14:19:05 2023

Version 23.2.0.0.0

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

Enter password:

ERROR:

ORA-12514: Cannot connect to database. Service FREE is not registered with the

listener at host 127.0.0.1 port 1521. (CONNECTION_ID=+wgWspJwEdfgUwEAAH9dmQ==)

Enter user-name: sys

Enter password:

ERROR:

ORA-12514: Cannot connect to database. Service FREEPDB1 is not registered with

the listener at host 127.0.0.1 port 1521.

(CONNECTION_ID=+wgWspJxEdfgUwEAAH9dmQ==)

Enter user-name: ^C

 

Below is the solution to resolve this error, there is one parameter called TWO_TASK, which we need to unset

 

[oracle@localhost Desktop]$ echo $ORACLE_SID

FREE

[oracle@localhost Desktop]$ echo $TWO_TASK

FREEPDB1

[oracle@localhost Desktop]$ unset TWO_TASK

 

Once you unset this parameter, connect using sqlplus as sysdba and try to start the database 

 

[oracle@localhost Desktop]$ sqlplus

SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Sat May 6 14:23:16 2023

Version 23.2.0.0.0

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

Enter user-name: /as sysdba

Connected to an idle instance.

SQL>

SQL> startup mount  

ORACLE instance started.

Total System Global Area 1608409424 bytes

Fixed Size                             10043728 bytes

Variable Size                       671088640 bytes

Database Buffers               922746880 bytes

Redo Buffers                        4530176 bytes

Database mounted.

SQL>

In this way, there is the solution for everything in oracle database

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Instagram
  •  Pin
  •  linkedin
  •  reddit

Oracle 23c : Changing Default PDB name "FREE" to customized using nid utility

 Atikh Shaikh     oracle, Oracle23c     No comments   

Oracle database 23c  was released in March 2023, developer version. Oracle has provided complete instructions to download and install oracle database 23c free version, Click here to know more.

In the free version, oracle has been given "FREE" as the container name and freepdb1 as the pluggable database name, suppose you want to change to "technodb", we can do it using the nid Oracle tool,  it comes default with the installation of Oracle software. 

  • old name - free
  • new name - technodb
  • oracle tool- nid

Step 1 : shutdown and startup database in mount state

 

[oracle@localhost Desktop]$ sqlplus sys@free as sysdba

 

SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Sat May 6 14:12:30 2023

Version 23.2.0.0.0

 

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

 

Enter password:

 

Connected to:

Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release

Version 23.2.0.0.0

 

SQL> show pdbs

 

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

           2 PDB$SEED                              READ ONLY  NO

           3 FREEPDB1                              READ WRITE NO

SQL>

SQL>

 

SQL> shu immediate

Database closed.

Database dismounted.

 

SQL> startup mount 

ORACLE instance started.

 

Total System Global Area 1608409424 bytes

Fixed Size             10043728 bytes

Variable Size         671088640 bytes

Database Buffers      922746880 bytes

Redo Buffers            4530176 bytes

Database mounted.

SQL> 

 

Step 2 : Run the nid tool to change database name for FREE to TECHNODB

 

[oracle@localhost Desktop]$ nid target = sys/oracle dbname=technodb

 

DBNEWID: Release 23.0.0.0.0 - Developer's Release on Sat May 6 14:25:53 2023

 

Copyright (c) 1982, 2023, Oracle and/or its affiliates.  All rights reserved.

 

Connected to database FREE (DBID=1405253007)

 

Connected to server version 23.2.0

 

Control Files in database:

    /opt/oracle/oradata/FREE/control01.ctl

    /opt/oracle/oradata/FREE/control02.ctl

 

Change database ID and database name FREE to TECHNODB? (Y/[N]) => Y

 

Proceeding with operation

Changing database ID from 1405253007 to 2754615793

Changing database name from FREE to TECHNODB

    Control File /opt/oracle/oradata/FREE/control01.ctl - modified

    Control File /opt/oracle/oradata/FREE/control02.ctl - modified

    Datafile /opt/oracle/oradata/FREE/system01.db - dbid changed, wrote new name

    Datafile /opt/oracle/oradata/FREE/pdbseed/system01.db - dbid changed, wrote new name

    Datafile /opt/oracle/oradata/FREE/sysaux01.db - dbid changed, wrote new name

    Datafile /opt/oracle/oradata/FREE/pdbseed/sysaux01.db - dbid changed, wrote new name

    Datafile /opt/oracle/oradata/FREE/users01.db - dbid changed, wrote new name

    Datafile /opt/oracle/oradata/FREE/pdbseed/undotbs01.db - dbid changed, wrote new name

    Datafile /opt/oracle/oradata/FREE/FREEPDB1/system01.db - dbid changed, wrote new name

    Datafile /opt/oracle/oradata/FREE/FREEPDB1/sysaux01.db - dbid changed, wrote new name

    Datafile /opt/oracle/oradata/FREE/FREEPDB1/undotbs01.db - dbid changed, wrote new name

    Datafile /opt/oracle/oradata/FREE/FREEPDB1/users01.db - dbid changed, wrote new name

    Datafile /opt/oracle/oradata/FREE/undotbs2.db - dbid changed, wrote new name

    Datafile /opt/oracle/oradata/FREE/temp01.db - dbid changed, wrote new name

    Datafile /opt/oracle/oradata/FREE/pdbseed/temp01.db - dbid changed, wrote new name

    Datafile /opt/oracle/oradata/FREE/FREEPDB1/temp01.db - dbid changed, wrote new name

    Control File /opt/oracle/oradata/FREE/control01.ctl - dbid changed, wrote new name

    Control File /opt/oracle/oradata/FREE/control02.ctl - dbid changed, wrote new name

    Instance shut down

 

Database name changed to TECHNODB.

Modify parameter file and generate a new password file before restarting.

Database ID for database TECHNODB changed to 2754615793.

All previous backups and archived redo logs for this database are unusable.

Database has been shutdown, open database with RESETLOGS option.

Succesfully changed database name and ID.

DBNEWID - Completed succesfully.

 

[oracle@localhost Desktop]$

 

Step 3 : Now open the database

 

[oracle@localhost Desktop]$ sqlplus 

 

SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Sat May 6 14:27:45 2023

Version 23.2.0.0.0

 

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

 

Enter user-name: /as sysdba

Connected to an idle instance.

SQL> startup

ORACLE instance started.

 

Total System Global Area 1608409424 bytes

Fixed Size                 10043728 bytes

Variable Size                      671088640 bytes

Database Buffers      922746880 bytes

Redo Buffers                        4530176 bytes

ORA-01103: control file database name 'TECHNODB' does not match parameter file

DB_NAME 'FREE'

 

At first, you will not be able to start the database as spfile has a different name

db_name than new name, use alter system command to change the db name

and use the scope as spfile

 

SQL> alter system set db_name =technodb scope=spfile;

 

System altered.

 

Shutdown the database

 

SQL> shu abort 

ORACLE instance shut down.

 

Now startup the database with resetlogs option and you are set with a new database name

 

SQL> startup

ORACLE instance started.

 

Total System Global Area 1608409424 bytes

Fixed Size             10043728 bytes

Variable Size         671088640 bytes

Database Buffers      922746880 bytes

Redo Buffers            4530176 bytes

Database mounted.

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

 

 

SQL> alter database open resetlogs;

 

Database altered.

 

SQL> show parameter db_name

 

NAME                     TYPE  VALUE

------------------ ----------- ------------------------------

db_name                  string     TECHNODB

SQL> 

SQL> 

 

We can see the database name has been changed from FREE to TECHNODB, you will not be able to change the instance name as this is a free edition.

 

 

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Instagram
  •  Pin
  •  linkedin
  •  reddit
Newer Posts Older Posts Home

Author

Atikh Shaikh
View my complete profile

Categories

  • MongoDB (18)
  • Oracle 12c (30)
  • Oracle12cR2 New Feature (3)
  • PostgreSQL (20)
  • RMAN (10)
  • Snowflake (8)
  • mysql (23)
  • oracle (74)

Blog Archive

  • ►  2018 (38)
    • ►  November (25)
    • ►  December (13)
  • ►  2019 (33)
    • ►  January (15)
    • ►  February (6)
    • ►  March (2)
    • ►  April (5)
    • ►  May (5)
  • ►  2020 (5)
    • ►  April (1)
    • ►  May (2)
    • ►  July (2)
  • ►  2021 (8)
    • ►  June (3)
    • ►  July (3)
    • ►  August (1)
    • ►  December (1)
  • ►  2022 (33)
    • ►  May (3)
    • ►  June (10)
    • ►  July (3)
    • ►  August (4)
    • ►  September (8)
    • ►  October (3)
    • ►  November (2)
  • ►  2023 (14)
    • ►  February (1)
    • ►  April (5)
    • ►  May (2)
    • ►  June (1)
    • ►  September (1)
    • ►  October (1)
    • ►  December (3)
  • ►  2024 (5)
    • ►  January (2)
    • ►  March (3)
  • ▼  2025 (6)
    • ►  March (1)
    • ►  April (3)
    • ▼  May (2)
      • Oracle 23ai : The all new Hybrid Read-Only for plu...
      • Oracle Active Data Guard Features and Benefits

Popular Posts

  • ORA-29283: invalid file operation: unexpected "LFI" error (1509)[29437]
    I was trying to export the schema in my windows PC, it got stuck with below error    C:\Users\shaik\Videos\technodba exp>expdp userid...
  • PostgreSQL : How to get data directory location for PostgreSQL instance
    Sometimes, you start working on a PostgreSQL instance but forget about the data directory, here we will discuss different methods to know th...
  • Oracle 23ai : Use of NOVALIDATE Constraints in IMPDP
    While performing impdp operations in the Oracle database, Oracle performs validation checks for every constraint on the imported table, that...
  • ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
    In previous articles, we have learned about user creation and grants  in MySQL in detail, but there are a few privileges called global priv...
  • Oracle Dataguard Broker Configuration (DGMGRL)
    Data Guard Broker is a command-line interface that makes managing primary and standby databases easy. DBA can use a single command to switch...

Labels

oracle Oracle 12c mysql PostgreSQL MongoDB oracle 19c Oracle23c oracle19c Orale PDB-CDB oracle12c python AWS Oracle ASM Virtualbox pluggable database storage engine

Pages

  • Disclaimer
  • Privacy Policy

Follow TechnoDBA

Copyright © Atikh's DBA blog | Powered by Blogger