Get basic information about a database through an SQL statement

Source: Internet
Author: User
Data | database | statement
You can learn about the state of the system and the status of the database immediately with the following SQL (dedicated to people who are accustomed to using sql/plus, hehe)
(1) Querying Oracle's physical structure
1.1. View data files
Sql> select name from V$datafile;
NAME
---------------------------------------------
/U05/DBF/PROD/SYSTEM_01.DBF/U05/DBF/PROD/SYSTEM_01.DBF (System data file)
/U06/DBF/PROD/TEMP_01.DBF (Temporary data file)
/U04/DBF/PROD/USERS_01.DBF (user data file)
/U09/DBF/PROD/RBS_01.DBF (rollback data file)
/U06/DBF/PROD/APPLSYS_INDX_01.DBF (index data file)
Data files are the most important physical files in Oracle

1.2. Query control File Information
Sql>select * from V$controlfile
1.3 View Log Group
Sql>select * from V$log
1.4. View the specific log member file
Sql>select * from V$logfile
1.5 Find the alert date to the file path through the following SQL
Select value from v$parameter where name = ' Background_dump_dest '
1.6 Find the path to the user trace file through the following SQL
Select value from v$parameter where name = ' User_dump_dest '


(2) Query security information
2.1 Displaying user information
SQL>SELELCT * from dba_users Where Username = ' System '
2.2 Displaying role information
sql> Select *from Dba_roles
2.2 Display table space limit information
Sql> Select Tablespace_name,username,bytes,max_bytes
Sql> from Dba_ts_quotas;
2.4 Displays the information of the start file and related resource restriction settings
Sql> Select Profile,resource_name,limit
Sql> from Dba_profiles;
2.5 Display all the tables owned by the current user
Sql> Select * from Tab;
2.6 View the SQL of the internal system table
SELECT * FROM V$fixed_view_definition

3 Querying Oracle's system environment variables
3.1. Find global shared buffers (SGA)
Sql> select * from V$SGA;
NAME VALUE
-------------------- ---------
Fixed Size 39816
Variable Size 259812784
Database buffers 1.049E+09
Redo buffers 327680
More detailed information can refer to V$sgastat, V$buffer_pool
For SQL statements saved in a shared pool, you can query from V$sqltext, V$sqlarea,

3.2 Clear Share_pool, keep data buffer
Sql> alter system flush Shared_pool;
System altered.

3.3. Run the following statement to get the system SCN number
Sql> Select Max (KTUXESCNW * Power (2) + KTUXESCNB) SCN from X$ktuxe;
Scn
----------
31014
3.4 Query data block free space size.
Select KVISVAL,KVISTAG,KVISDSC from Sys.x$kvis;

3.5 Check the current Oracle connection type:
Select Server
From V$session
where Audisid=userenv (' SESSIONID ');
If the output
SERVER
―――――――――――
Dedicated

Indicates that the current Oracle connection is practical for dedicated server connections, not MTS multi-threaded servers (SHARED)

3.6. View the SQL of the data dictionary
SELECT * FROM Dict

3.7 Checking the status of background threads
Select name,description
From v$bgprocess
Where paddr<> ' 00 ' (process address is not equal to ' 00 ')
The output is similar to the results:
Name Description
--------    ---------------------------------
Pmon Process Cleanup
DBWO db Writer Process 0
LGWR Redo ETC
CKPT checkpoint
。。。 。。。
3.8 Display Table Structure
DESC TableName (arbitrary table name);
The output is similar to the results:
Name null? Type
---------------------------- --------------------  ------------------
ID not Null number (30)

I hope this article will be a starting point, and I hope you can share the SQL commands that you think are important or commonly used below.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.