Home Database Mysql Tutorial Oracle数据库基本常用命令汇总

Oracle数据库基本常用命令汇总

Jun 07, 2016 pm 04:20 PM
oracle Order Basic Commonly used database Summary

以下是对Oracle中的数据库基本常用命令进行了总结介绍,需要的朋友可以过来参考下 1、得到数据库名和创建日期 SELECT name, created, log_mode, open_mode FROM v$database; 2、ORACLE数据库的计算机的主机名,ORACLE数据库的实例名及ORACLE数据库管理系统的

以下是对Oracle中的数据库基本常用命令进行了总结介绍,需要的朋友可以过来参考下

 

1、得到数据库名和创建日期
SELECT name, created, log_mode, open_mode FROM v$database;

2、ORACLE数据库的计算机的主机名,,ORACLE数据库的实例名及ORACLE数据库管理系统的版本信息
SELECT host_name, instance_name, version FROM v$instance;

3、为了知道oracle数据库版本的一些特殊信息
select * from v$version;

4、获取控制文件名字
select * from v$controlfile;

5、得到Oracle数据库的重做日志配置信息
SELECT group#, members, bytes, status, archived FROM v$log;
select GROUP#,MEMBER from v$logfile;

6、获取oracle的每个重做日志(成员)文件所存放的具体位置
select * from v$logfile;

7、知道ORACLE数据库的备份和恢复策略和归档文件的具体位置
archive log list

8、知道ORACLE数据库中到底有多少表空间以及每个表空间的状态
select tablespace_name, block_size, status, contents, logging from dba_tablespaces;
select tablespace_name, status from dba_tablespaces;

9、知道每个表空间存在哪个磁盘上以及文件的名字等信息
SELECT file_id, file_name, tablespace_name, status, bytes from dba_data_files;
select file_name, tablespace_name from dba_data_files;

10、知道Oracle数据库系统上到底有多少用户和都是什么时候创建的
select username,created from dba_users;
select username, DEFAULT_TABLESPACE from dba_users;

11、从控制文件中取出信息涉及到以下一些相关的命令

复制代码 代码如下:


select * from v$archived
select * from v$archived_log
select * from v$backup
select * from v$database
select * from v$datafile
select * from v$log
select * from v$logfile
select * from v$loghist
select * from v$tablespace
select * from v$tempfile


12、控制文件由两大部份组成:可重用的部份和不可重用的部分。可重用的部分的大小可用CONTROL_FILE_RECORD_KEEP_TIME 参数来控制,该参数的默认值为7天,即可重用的部份的内容保留7天,一周之后这部份的内容可能被覆盖。可重用的部份是供恢复管理器来使用的,这部份的内容 可以自动扩展。Oracle数据库管理员可以使用CREAT DATABASE或 CREAT CONTROLFILE语句中的下列关键字(参数)来间接影响不可重用的部份的大小:

复制代码 代码如下:


MAXDATAFILES
MAXINSTANCES
MAXLOGFILES
MAXLOGHISTORY
MAXLOGMEMBERS


13、查看控制文件的配置
SELECT type, record_size, records_total, records_used  FROM v$controlfile_record_section;

14、如果您的显示被分成了两部分,您需要使用类似于set pagesize 100的SQL*Plus命令先格式化输出。有关的格式化输出命令有以下这些:
record_size:  为每个记录的字节数。
records_total:为该段所分配的记录个数。
records_used:为该段所使用的记录个数。

15、知道控制文件中的所有数据文件(DATAFILE),表空间(TABLESPACE),和重做日志(REDO LOG)所使用的记录情况
SELECT type, record_size, records_total, records_used
FROM  v$controlfile_record_section
WHERE type IN ( ‘DATAFILE', ‘TABLESPACE', ‘REDO LOG');

16、获取控制文件名字
select value from v$parameter where name ='control_files';
或者:select * from v$controlfile

17、如何在一个已经安装的Oracle数据库中添加或移动控制文件呢?
以下是在一个已经安装的Oracle数据库中添加或移动控制文件的具体步骤:

a、利用数据字典v$controlfile来获取现有控制文件名字。

b、正常关闭Oracle数据库。

c、将新的控制文件名添加到参数文件的CONTROL_FILES参数中。

d、使用操作系统的复制命令将现有控制文件复制到指定位置。

e、重新启动Oracle数据库。

f、利用数据字典v$controlfile来验证新的控制文件名字是否正确。

g、如果有误重做上述操作,如果无误删除无用的旧控制文件。

注: 如果您使用了服务器初始化参数文件(SPFILE),您不能关闭Oracle数据库而且应该在第3步使用alter system set control_files的Oracle命令来改变控制文件的位置。

复制代码 代码如下:


SQL> alter system set control_files =
‘D:Disk3CONTROL01.CTL',
‘D:Disk6CONTROL02.CTL',
‘D:Disk9CONTROL03.CTL' SCOPE=SPFILE;


18、由于控制文件是一个极其种要的文件,除了以上所说的将控制文件的多个副本存在不同的硬盘上的保护措施外,在数据库的结构变化之后,您应立即对控制文件进行备份。可以用Oracle命令来对控制文件进行备份:
alter database backup controlfile to ‘D:backupcontrol.bak';

19、您也可将备份到一个追踪文件中。该追踪文件包含有重建控制文件所需的SQL语句。可使用以下SQL语句来产生这一追踪文件:
alter database backup controlfile to trace;

20、正常关闭oracle命令
shutdown immeditae

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

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.

Undress AI Tool

Undress AI Tool

Undress images for free

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 Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1252
24
MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

How to create cursors in oracle loop How to create cursors in oracle loop Apr 12, 2025 am 06:18 AM

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

Why Use MySQL? Benefits and Advantages Why Use MySQL? Benefits and Advantages Apr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

How to export oracle view How to export oracle view Apr 12, 2025 am 06:15 AM

Oracle views can be exported through the EXP utility: Log in to the Oracle database. Start the EXP utility, specifying the view name and export directory. Enter export parameters, including target mode, file format, and tablespace. Start exporting. Verify the export using the impdp utility.

What to do if the oracle log is full What to do if the oracle log is full Apr 12, 2025 am 06:09 AM

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.

MySQL vs. Other Databases: Comparing the Options MySQL vs. Other Databases: Comparing the Options Apr 15, 2025 am 12:08 AM

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.

What steps are required to configure CentOS in HDFS What steps are required to configure CentOS in HDFS Apr 14, 2025 pm 06:42 PM

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

Oracle's Role in the Business World Oracle's Role in the Business World Apr 23, 2025 am 12:01 AM

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

See all articles