Oracle常用命令随笔

Oracle常用命令

  • 基础篇

基础篇

–创建表空间

CREATE   TABLESPACE ‘create_name’
DATAFILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\create_name.DBF' size 500m
AUTOEXTEND ON 
NEXT 200M MAXSIZE 20480M 
EXTENT MANAGEMENT LOCAL;

–创建临时表空间

CREATE TEMPORARY TABLESPACE create_name
TEMPFILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\create_name.DBF'
SIZE 200M
AUTOEXTEND ON
NEXT 50M MAXSIZE 20480M
EXTENT MANAGEMENT LOCAL;

–创建用户并指定表空间和临时表空间

CREATE USER ‘userName’ IDENTIFIED BY ‘password’
DEFAULT TABLESPACE name
TEMPORARY TABLESPACE name_temp;
grant dba to 用户名  ----授权命令

–查看表空间信息

SELECT * FROM DBA_DATA_FILES

–查看解锁用户

alter user scott account unlock;

–查看哪个表被锁

select b.owner,b.object_name,a.session_id,a.locked_mode  
from v$locked_object a,dba_objects b  
where b.object_id = a.object_id; 

–查看是哪个session引起的

select b.username,b.sid,b.serial#,logon_time  
from v$locked_object a,v$session b  
where a.session_id = b.sid order by b.logon_time;

–杀掉对应进程来解锁

alter system kill session'sid_value, serial#_value';

你可能感兴趣的:(日常笔记)