–查看 版本信息
select * from v$version;
– 解锁用户
alter user scott account unlock;
– 锁定用户
alter user scott account lock;
– 设置密码(解锁需要设置密码)
alter user tom identified by tiger;
– 查看当前登录的用户。
show user;
– 查看用户表
select username,account_status,default_tablespace from dba_users;
– 创建用户和密码,默认用户名大写,想保存原样使用 双引号 创建,新创建用户需要设置密码
create user tom ; – 大写 TOM
create user “Tom” ; – 原样 Tom
alter user tom identified by oracle;
– 删除用户
drop user “Tom”;
– 授权 登陆
grant create session to tom;
– 授权 增加 建表 增删改查
grant create table to tom;
– 授权用户 表空间
alter user tom quota 100m on test;
– 赋予用户的表空间权限
alter user tom default tablespace test;
–授权用户查询另一个用户的表数据
grant select on scott.emp to tom; –单独表
– 查看当前用户权限
select * from user_sys_privs;
– 撤销权限
revoke create table from tom;
– 查看各种缓存大小
select name,bytes/1024/1024||’MB’ from v$sgainfo;
– 查看表空间 物理位置
select * from dba_data_files;
– 查询当前存在的表空间:
select * from v$tablespace;
– 查询表空间大小
select tablespace_name,sum(bytes)/1024/1024 from dba_data_files group by tablespace_name;
– 查看表空间剩余大小
select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by tablespace_name;
– 创建表空间 ,末尾带autoextend on参数表示当表空间大小不够用时会自动扩容
create tablespace test datafile ‘/u01/app/oracle/oradata/orcl/test.dbf’ size 100m autoextend on;
– 修改表空间大小
alter database datafile ‘/u01/app/oracle/oradata/orcl/test.dbf’ resize 100m;
– 删除表空间
drop tablespace test including contents and datafiles;
– 查看用户当前连接数
select count(*) from sys.v_$session;
–修改连接数
alter system set processes=30 scope=spfile;