---
title: "Oracle常用语句"
author: "panfuy"
date: "2011-11-01T17:58:46Z"
tags: ["parameter", "processes", "session", "sessions", "show"]
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2011-11-02T12:20:37Z"
id: 1226955
url: "https://panfuy.iteye.com/blog/1226955"
---

首先需要知道你登录的用户名，然后以sysdba登录，然后执行下列的语句：

在系统命令行输入sqlplus  [/@sid]() as sysdba

 

--查询最大线程数量  
show parameter processes

 

--查询最大会话数量   
show parameter sessions

 

--查询当前使用会话数量  
select count(\*) from v$session;  
   
\--查询当前数据库文件存放位置  
show parameter spfile;

 

--修改processes

alter system set processes=300 scope=spfile;

--修改sessions值  
alter system set sessions=335 scope=spfile;

--修改后要重启数据库，更改才生效。  
shutdow immediate;  
\--启动

startup;

 

  

--查看用户使用的缺省表空间名称  
sqlplus  as sysdba   select username,default\_tablespace from dba\_users;

 

--查看表空间总大小，及其已使用大小  
select a.tablespace\_name,a.bytes10241024 Sum MB,(a.bytes-b.bytes)10241024 used MB,b.bytes10241024 free MB,   round(((a.bytes-b.bytes)a.bytes)100,2) percent\_used   from   (select tablespace\_name,sum(bytes) bytes from dba\_data\_files group by tablespace\_name) a,   (select tablespace\_name,sum(bytes) bytes,max(bytes) largest from dba\_free\_space group by tablespace\_name) b   where a.tablespace\_name=b.tablespace\_name   order by ((a.bytes-b.bytes)a.bytes) desc;

 

--查询文件存放位置  
select name from v$datafile;

--查询dba表空间  
select tablespace\_name from dba\_tablespaces;

 

--查询dba所有用户  
select * from dba\_users;

 

--查询最新执行sql的前10条  
select * from V$SQL where rownum &lt;10;