我们的团队服务宗旨是: 拥有较强的ERP团队,帮助您的企业实现信息化, 拥有ERP周边配套系统的开发和维护经验的团队,为您的企业信息化提供整套的服务,ERP和WEB的开发。ERP 采用D2K开发,团队人员拥有来自电子半导体制造企业的ERP 3至4年以上系统开发和维护经验,熟悉制造企业的流程和ERP企业运作流程,不断更新的知识为您的企业服务,优质的服务是您放心的选择. 給自己一個空間,給心靈一個空間,欢迎您我的朋友,MSN: yucheng_sam@hotmail.comQQ : 106786879

ORACLE DBA日常管理SQL語句小結

上一篇 / 下一篇  2008-01-09 19:11:05 / 个人分类:SQL

 关闭/启用用户(进程)追踪

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;

 

--启用所有角色


TAG:

引用 删除 Guest   /   2008-08-27 22:09:09
好手,小弟也是做ERP的,有好的工作机会招呼一声!我邮箱是:hengxing_kong@163.com
 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-10-07  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 2750
  • 日志数: 45
  • 图片数: 4
  • 文件数: 2
  • 建立时间: 2007-12-28
  • 更新时间: 2008-08-26

RSS订阅

Open Toolbar