--创建一个用户
create user xiaoyi identified by root;
--修改用户的密码
alter user xiaoyi identified by root;
--查看用户所拥有的表空间
select * from dba_users t where t.username='XIAOYI';
--创建一个表空间
create tablespace xy datafile 'F:\app\mytablespace\xy_data.dbf' size 1000m;
--将表空间分配给用户
alter user xiaoyi default tablespace xy;
--给用户分配权限
grant create session,create table,create view,create sequence,unlimited tablespace to xiaoyi;
--查询用户所具有的权限
select * from session_privs;
--删除用户
drop use xiaoyi cascade;
--给锁定的账户解锁
alter user xiaoyi account unlock;
--重命名表空间
alter tablespace xy rename to xy1;
--查看表空间
SELECT a.tablespace_name "表空间名",
total "表空间大小",
free "表空间剩余大小",
(total - free) "表空间使用大小",
total / (1024 * 1024 * 1024) "表空间大小(G)",
free / (1024 * 1024 * 1024) "表空间剩余大小(G)",
(total - 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