关闭/启用用户(进程)追踪
ALTER session set sql_trace=false/ture
显示数据库的基本信息
SELECT name,created,log_mode,open_mode
from v$database;
显示数据库的基本信息
select host_name,instance_name,version
from v$instance;
显示数据库的版本信息、
select * from
v$version;
显示数据库的重做日志配置信息、
select group#,members,bytes,status,archived
from v$log;
显示数据库的重做日志的位置和状态
select * from v$logfile;
归档文件的具体位置
archive log list;
显示表空间的基本信息
select tablespace_name,block_size,status,contents,logging
from dba_tablespaces
显示每个表空间所属的数据文件的文件号,文件名状态等
select file_id,file_name,tablespace_name,status,bytes
from dba_data_files
显示控制文件中全部记录的相关信息
select type,record_size,records_total,records_used
from v$controlfile_record_section
---控制文件的备份
ALTER database backup controlfile
to 'd:\backup\control.bak';
---增加重做日志组
alter database add logfile
('e:\disk3\redo04a.log','e:\disk6\redo04b.log') size 15m;
删除重做日志组
alter database drop logfile group 4;
为重做日志组增加成员
alter database add logfile member 'c:\orant11\oradata\mis\redo02b.log' to group 2;
切换当前的日志组
alter system switch logfile;
清楚联机重做日志文件
alter database clear logfile group 4;
alter database clear unarchived logfile group 4;清楚联机重做日志文件
设置每个重做日志成员存放目录
alter system set db_create_online_log_dest_1 = 'e:\disk3';
增加重做日志组(放在默认的位置)
alter database add logfile;
创建数据字典管理表空间
create tablespace jinlian
datafile 'e:\disk2\moon\jinlian01.dbf' size 50m,
'e:\disk4\moon\jinlian02.dbf' size 50m
minimum extent 50 k extent management dictionary
default storge (initial 50 k next 50 k maxextents 100 pctincrease 0)
select tablespace_name,block_size, 显示表空间的基本信息
extent_management,segment_space_management
from dba_tablespaces;
create tablespace jinlian_index 创建本地管理表空间
datafile 'e:\disk6\moon\jinlian_index.dbf' size 50 m
extent management local
uniform. size 1m;
create undo tablespace jinlian_undo 创建还原表空间
datafile 'e:\disk7\moon\jinlian_undo.dbf'
size 20 m;
create temporary tablespace jinlian_temp 创建临时表空间
tempfile 'e:\disk8\moon\jinlian_temp.dbf'
size 10 m
extent management local
uniform. size 2 m;
alter database 将TEMP表空间修改为临时表空间
default temporary tablespace jinlian_temp;
alter database 将临时表空间修改为TEMP表空间
default temporary tablespace temp;
alter tablespace jinlian offline; 将JINLIAN表空间设置为脱机状态
alter tablespace jinlian online; 将JINLIAN表空间设置为联机状态
alter tablespace jinlian read only; 将JINLIAN表空间设置为只读状态
select tablespace_name,status,contents查询表空间的相关信息
from dba_tablespaces
where tablespace_name like 'JIN%';
alter tablespace jinlian minimum extent 100 k;将JINLIAN表空间最小存储设置为100K
alter tablespace jinlian 将JINLIAN表空间存储设置为100K
default stotage (initial 100 k next 100 k maxextents 200 );
select file#,name,status 查询该表空间数据文件的状态
from v$datafile
where file#>=8;
alter database datafile 让JINLIAN_index大小在达到最大时可以自动扩展
'e:\disk6\moon\jinlian_index.dbf' autoextend on next 1 M;
alter database datafile 将JINLIAN表空间所对应的数据文件加大到100M
'e:\disk2\moon\jinlian01.dbf' resize 100 m;
alter tablespace jinlian 为JINLIAN表空间增加一个新数据文件来增加表空间的尺寸
add datafile 'e:\disk6\moon\jinlian03.dbf' size 80 M;
create user dog 创建用户
identified by wangwang
default tablespace jinlian
temporary tablespace jinlian_temp
quota 68m on jinlian_temp
quota 28m on users
password expire
alter user dog 修改分配给用户的空间大小
quota 0 on users;
alter user dog 修改分配给用户的空间大小
quota 38m on jinlian_temp;
--移动数据文件位置4个步骤
alter tablespace users offline; 1将表空间设置成脱机
host copy d:\orant11\oradata\mis\users01.dbf 2复制要移动的文件到位置
d:\disk2\oradata\
alter tablespace users rename 3重新命名表空间的的数据文件名
datafile 'd:\orant11\oradata\mis\users01.dbf'
to 'd:\disk2\oradata\users01.dbf';
alter tablespace users online; 4将表空间设置成联机
execute dbms_space_admin.tablespace_migrate_to_local('JINLIAN'); 将表空间迁移为本地管理
execute dbms_space_admin.tablespace_migrate_from_local('JINLIAN');将表空间迁移为数据字典管理的表空间
drop tablespace jinlian; 删除表空间,但是系统里依然有这个文件,只删除指向数据文件的指针
drop tablespace jinlian_index including contents and datafiles;删除表空间包括段和数据文件
-----------OMF管理设定
OMF管理设定数据文件存放的目录
alter system set
db_create_file_dest ='d:\disk5\oradata'
create tablespace guifei;
alter tablespace guifei add datafile size 50 M为表空间guifei添加一个新文件
drop tablespace guifei; 删除
create user jack_bery identified by jack001 创建用户
default tablespace jack_bery_01
temporary tablespace temp
profile default
quota 100m on jack_bery_01
创建用户(加锁)系统管理员开锁以后才可登陆使用
create user tax01 identified by tax01
default tablespace jack_bery_01
temporary tablespace temp
profile default
quota 100m on jack_bery_01
account lock;
--创建用户,增加确定有效口令管理
create user tax02 identified by tax02
default tablespace jack_bery_01
temporary tablespace temp
profile default
quota 100m on jack_bery_01
password expire
--修改用户信息
alter user tax02 identified by tax02;
--查询用户和角色信息
select
username,granted_role,admin_option
from user_role_privs
select role,password_required from dba_roles;
--修改角色信息
alter role tax_members identified by tax_members;
--查询角色信息
select * from session_roles;
--停用所有角色
set role none;
--启用所有角色