Home Database Oracle How to view oracle database

How to view oracle database

May 07, 2023 pm 10:52 PM

Oracle database is a very popular relational database management system, mainly used for enterprise-level applications and data processing tasks. In the Oracle database, administrators need to frequently check the status and content of the database to ensure that it is running correctly and providing high-availability services. This article will introduce how to view the basic information, status and content of the Oracle database.

  1. View database instance information

To view basic information about an Oracle database instance, you can use SQL*Plus or Oracle Enterprise Manager (OEM).

After using SQL*Plus to connect to a database instance, you can use the following command to view the instance name, version, startup time, and current connected user:

SELECT INSTANCE_NAME, VERSION, STARTUP_TIME, USERNAME
FROM v$instance;

In addition, you can also use the following command to view the instance CPU And memory usage:

SELECT name, value
FROM v$osstat
WHERE name IN ('NUM_CPUS', 'NUM_CPU_CORES', 'PHYSICAL_MEMORY_BYTES');

If you are using Oracle Enterprise Manager, you can view the basic information of the database instance, including version, startup time, status, etc., from the "Instance" tab on the main interface.

  1. View database space status

Database space refers to the logical and physical storage space used when storing and managing data in the Oracle database. To view the database space status, you can use the following SQL statement:

SELECT tablespace_name, total_space, free_space, (total_space-free_space) used_space
FROM (
  SELECT tablespace_name, SUM(bytes) free_space
  FROM dba_free_space
  GROUP BY tablespace_name
), (
  SELECT tablespace_name, SUM(bytes) total_space
  FROM dba_data_files
  GROUP BY tablespace_name
)
WHERE tablespace_name NOT LIKE '%TEMP%'
ORDER BY tablespace_name;

This SQL statement will display the total space and free space for each table space, and calculate the value of the used space.

  1. View database performance and health

Oracle database has many performance and health metrics, including number of connections, response time, resource usage, etc. The following are some commonly used monitoring instructions:

  • View the current number of connections:
SELECT COUNT(*) FROM v$session;
  • View the query response time:
SELECT SQL_ID, EXECUTIONS, ELAPSED_TIME/1000000 sec,
  BUFFER_GETS, DISK_READS, ROWS_PROCESSED
FROM v$sql
ORDER BY ELAPSED_TIME DESC;
  • View disk I/O activity:
SELECT name, value 
FROM v$sysstat 
WHERE name IN ('physical reads', 'physical writes');

In addition, Oracle also provides many tools such as Enterprise Manager and Diagnostics Pack for viewing database performance and health.

  1. View log files

Log files are files used to record system and application events in the Oracle database. They help administrators view system warnings and errors and track troubleshooting.

You can use the following SQL command to view the log file:

  • View the warning log:
SELECT TIMESTAMP, MESSAGE FROM v$system_warnings;
  • View the error log:
SELECT TIMESTAMP, MESSAGE FROM v$diag_alert_ext 
WHERE MESSAGE_TEXT LIKE '%ERROR%';

In Oracle Enterprise Manager, you can view system warning and error information in the "Warnings and Reactions" tab.

  1. View sessions and locks

Session refers to the session information and status that is maintained in Oracle database in contact with client requests. To view the status and content of the current session, you can execute the following command:

SELECT s.sid, s.status, s.username, s.osuser, s.machine, 
       s.program, s.logon_time, m.sql_text
FROM v$session s 
LEFT OUTER JOIN v$sql m ON s.sql_id = m.sql_id
WHERE s.type != 'BACKGROUND';

This SQL statement will return the SID, status, user name, operating system user, computer name, program name, login time, and current session The SQL statement being executed (if any).

Locking is an important tool for controlling concurrent access in Oracle database. To view the current lock situation, you can use the following command:

SELECT l.session_id, s.username, s.osuser, s.machine, s.program, 
       l.lock_type, l.mode_held, l.mode_requested, o.object_type, 
       o.owner || '.' || o.object_name
FROM v$lock l 
JOIN v$session s ON l.session_id = s.sid 
JOIN dba_objects o ON l.id1 = o.object_id;

This SQL statement will display the currently locked session ID, user name, operating system user, computer name, program name, lock status, holding mode, request Schema, object type, and object name.

Summary

In the Oracle database, viewing basic information, status and content is something that system administrators often need to do. This article introduces some SQL commands and tools that can help administrators quickly view the status and contents of the database, as well as monitor performance and health. At the same time, Oracle Enterprise Manager also provides a very rich graphical interface and automated management tools, which can further help administrators better manage Oracle databases.

The above is the detailed content of How to view oracle database. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use the WITH clause in Oracle How to use the WITH clause in Oracle Aug 21, 2025 am 08:28 AM

TheWITHclauseinOracle,alsoknownassubqueryfactoring,enablesdefiningcommontableexpressions(CTEs)forimprovedqueryreadabilityandperformance.1.ThebasicsyntaxusesWITHcte_nameAS(SELECT...)followedbyamainqueryreferencingtheCTE.2.AsingleCTEexamplecomputesaver

How to create a sequence in Oracle? How to create a sequence in Oracle? Aug 13, 2025 am 12:20 AM

Use the CREATESEQUENCE statement to create sequences, which are used to generate unique values, often used for primary or proxy keys; 2. Common options include STARTWITH, INCREMENTBY, MAXVALUE/MINVALUE, CYCLE/NOCYCLE and CACHE/NOCACHE; 3. Get the next value through NEXTVAL, and CURRVAL gets the current value; 4. You can use sequence values to insert data in the INSERT statement; 5. It is recommended to avoid cache to prevent the loss of values due to crashes, and the sequence values will not be released due to transaction rollback; 6. Use DROPSEQUENCE to delete sequences when no longer needed.

What is the difference between a view and a materialized view in Oracle? What is the difference between a view and a materialized view in Oracle? Aug 13, 2025 am 08:29 AM

Aviewdoesnotstoredataphysicallyandexecutestheunderlyingqueryeachtimeitisaccessed,whileamaterializedviewstoresthequeryresultasaphysicaltable.2.Materializedviewsgenerallyofferfasterqueryperformancebecausetheyaccessprecomputeddata,whereasviewscanbeslowe

How to troubleshoot ORA-12541: TNS:no listener How to troubleshoot ORA-12541: TNS:no listener Aug 13, 2025 am 01:10 AM

First, confirm whether the listener on the database server has been started, use lsnrctlstatus to check, if it is not running, execute lsnrctlstart to start; 2. Check whether the HOST and PORT settings in the listener.ora configuration file are correct, avoid using localhost, and restart the listener after modification; 3. Use the netstat or lsof command to verify whether the listener is listening on the specified port (such as 1521). The client can test port connectivity through telnet or nc; 4. Ensure that the server and network firewall allow the listening port communication, the Linux system needs to be configured with firewalld or iptables, and Windows needs to enable inbound

Oracle JDBC connection string example Oracle JDBC connection string example Aug 22, 2025 pm 02:04 PM

Usejdbc:oracle:thin:@hostname:port:sidforSID-basedconnections,e.g.,jdbc:oracle:thin:@localhost:1521:ORCL.2.Usejdbc:oracle:thin:@//hostname:port/service_nameforservicenames,requiredforOracle12c multitenant,e.g.,jdbc:oracle:thin:@//localhost:1521/XEPDB

ORA-01017: invalid username/password; logon denied ORA-01017: invalid username/password; logon denied Aug 16, 2025 pm 01:04 PM

When encountering an ORA-01017 error, it means that the login is denied. The main reason is that the user name or password is wrong or the account status is abnormal. 1. First, manually check the user name and password, and note that the upper and lower case and special characters must be wrapped in double quotes; 2. Confirm that the connected service name or SID is correct, and you can connect through tnsping test; 3. Check whether the account is locked or the password expires, and the DBA needs to query the dba_users view to confirm the status; 4. If the account is locked or expired, you need to execute the ALTERUSER command to unlock and reset the password; 5. Note that Oracle11g and above versions are case-sensitive by default, and you need to ensure that the input is accurate. 6. When logging in to special users such as SYS, you should use the assysdba method to ensure the password.

How to install Oracle Database How to install Oracle Database Aug 29, 2025 am 07:51 AM

Ensure that the system meets prerequisites such as hardware, operating system and swap space; 2. Install the required software packages, create oracle users and groups, configure kernel parameters and shell restrictions; 3. Download and decompress the Oracle database software to the specified directory; 4. Run runInstaller as oracle user to start graphical or silent installation, select the installation type and execute the root script; 5. Use DBCA to create the database silently and set the instance parameters; 6. Configure ORACLE_BASE, ORACLE_HOME, ORACLE_SID and PATH environment variables; 7. Start the instance through sqlplus/assysdba and verify the database status, confirm that the installation is successful,

How to find the second highest salary in Oracle How to find the second highest salary in Oracle Aug 19, 2025 am 11:43 AM

To find the second highest salary in Oracle, the most commonly used methods are: 1. Use ROW_NUMBER() or RANK(), where ROW_NUMBER() assigns a unique sequence number to each row, which is suitable for obtaining the second row of data. RANK() will skip subsequent rankings when processing parallelism; 2. Use MAX() and subqueries to pass SELECTMAX(salary)FROMemployeesWHEREsalary

See all articles