Oracle Startup / Shutdown / Status Check
Open SQL Shell
- Login as oracle user
- Open sqlplus shell
# sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Thu Dec 24 23:26:47 2020
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>
Database Startup
- Start the Database
SQL> startup;
ORACLE instance started.
Total System Global Area 771751936 bytes
Fixed Size 8797536 bytes
Variable Size 566231712 bytes
Database Buffers 192937984 bytes
Redo Buffers 3784704 bytes
Database mounted.
Database opened.
Database Shutdown
- Stop the Database
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
Database Status Check
- Check Database uptime
- Show Service Name
- Check Current DB Version
- Check Installed DB Version
- Connect to a Specific Database
- Show All Database Names
- Show All Tablespaces
- Show Views in the Database
- Find all active locks on tables within the session
SQL> SELECT to_char(startup_time,'DD-MON-YYYY HH24:MI:SS') "DB Startup Time" FROM sys.v_$instance;
DB Startup Time
-----------------------------
24-DEC-2020 22:26:33
SQL> show parameter service_name;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string CDB1234
SQL> SELECT banner FROM v$version WHERE ROWNUM = 1;
BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> SELECT * FROM V$VERSION;
BANNER
--------------------------------------------------------------------------------
CON_ID
----------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
0
PL/SQL Release 12.2.0.1.0 - Production
0
CORE 12.2.0.1.0 Production
0
BANNER
--------------------------------------------------------------------------------
CON_ID
----------
TNS for Linux: Version 12.2.0.1.0 - Production
0
NLSRTL Version 12.2.0.1.0 - Production
0
sqlplus 'system/oracle@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=192.168.50.17)(Port=1521))(CONNECT_DATA=(SID=THE_SID)))'
SQL> SELECT TABLESPACE_NAME FROM USER_TABLESPACES;
TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
SQL> SELECT file_name, tablespace_name, ROUND(bytes/1024000) MB FROM dba_data_files ORDER BY 1;
FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME MB
------------------------------ ----------
/u01/app/oracle/oradata/CDB1234/sysaux01.dbf
SYSAUX 481
/u01/app/oracle/oradata/CDB1234/system01.dbf
SYSTEM 829
/u01/app/oracle/oradata/CDB1234/undotbs01.dbf
UNDOTBS1 72
FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME MB
------------------------------ ----------
/u01/app/oracle/oradata/CDB1234/users01.dbf
USERS 5
SQL> SELECT view_name, owner FROM sys.all_views where VIEW_NAME LIKE 'SCHEMA_%' ORDER BY owner, view_name;
VIEW_NAME
--------------------------------------------------------------------------------
OWNER
--------------------------------------------------------------------------------
SCHEMA_EXPORT_OBJECTS
SYS
SCHEMA_EXPORT_PATHS
SYS
SQL> select c.owner, c.object_name, c.object_type, b.sid, b.serial#, b.status, b.osuser, b.machine from v$locked_object a , v$session b, dba_objects c where b.sid = a.session_id and a.object_id = c.object_id;