Oracle日常操作

以下操作均以sysdba权限登陆数据库


关于用户部分操作

查询数据库中的用户名

select username from dba_users;

查询用户状态

select username,default_tablespace,temporary_tablespace,account_status from dba_users;

创建数据库用户

create user 用户名 identified by 密码;

创建指定表空间的用户

create user 用户名 identified by 密码 account unlock default tablespace 默认表空间名 temporary tablespace 临时表空间名;

解锁用户

alter user 用户名 account unlock;

修改用户密码

alter user 用户名 identified by 密码;

用户授权

grant connect,resource,dba to 用户名;

修改用户默认表空间

alter user 用户名 default tablespace 表空间名;

查询当前用户下都有哪些表

select table_name from user_tables;


关于表空间部分操作

查询表空间名称

select tablespace_name from dba_tablespaces;

创建表空间

create tablespace 表空间名 datafile '+DATA'  size 30g;

create tablespace 表空间名 datafile '+DATA' size 500M reuse autoextend on next 100M maxsize 2G;

表空间用户配额授权

alter user 用户名 quota unlimited on 表空间名;

扩展表空间

alter tablespace 表空间名 add datafile '+DATA' size 10g; #增加数据文件方式

alter database datafile '+DATA/xxx/xxxxxxx.dbf' resize 20g;  #改变已存在表空间文件大小

alter database datafile '+DATA/xxx/xxxxxxx.dbf' autoextend on next 100m maxsize 20g; #允许自动增长


管理审计功能

show parameter audit

alter system set audit_trail=none scope=spfile

shutdown immediate

startup


关于SQL部分操作

查询历史sql执行记录

select SQL_TEXT,to_char(LAST_ACTIVE_TIME,'yyyy-mm-dd hh24:mi:ss') from v$sql

查询并处理死锁

select object_name,machine,s.sid,s.serial# from v$locked_object l,dba_objects o,v$session s where l.object_id = o.object_id and l.session_id = s.sid;

alter system kill session '113,123';

查看表空间使用情况

SELECT a.tablespace_name "表空间名称", total / (1024 * 1024 * 1024) "表空间大小(G)", free / (1024 * 1024 * 1024) "表空间剩余大小(G)", round((total - free) / total, 4) * 100 "使用率 %" FROM (SELECT tablespace_name, SUM(bytes) free FROM dba_free_space GROUP BY tablespace_name) a, (SELECT tablespace_name, SUM(bytes) total FROM dba_data_files GROUP BY tablespace_name) b WHERE a.tablespace_name = b.tablespace_name;


RAC部分操作

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值