select * from dba_tab_privs
--创建基础用户
create user student identified by abc
--修改用户口令
alter user student identified by cba
--修改用户状态
alter user student account lock;
--修改用户表空间
alter user student default tablespace users temporary tables temp;
--链接数据库权限
grant connect to student
--分配查看权限
grant insert,update,delete,select on scott.emp to student
--分配查看权限 可以往下传播 给下一个用户
grant insert,update,delete,select on scott.emp to student with grant option
--没收权限,cascade constriants还会没收此用户通过with grant option传播出去的该权限(递归)
revoke update on scott.emp from studnet cascade constraints;
--数据字典
--创建及角色
create role lisi
--给角色分配权限
grant select,insert,update on scott.emp to lisi
--回收权限
revoke select,insert,update on scott.emp to lisi
--授予角色的对象权限
select * from role_tab_privs;
--授予另一个角色的权限
select * from role_role_privs;
--包含授予权限角色的对象权限
select * from role_sys_privs;
--直接授予用户帐户的对象权限
select * from dba_tab_privs
--授予用户帐户的系统权限
select * from dba_sys_privs
--直接授予用户帐户的对象权限
select * from dba_tab_privs
--删除用户 连同模式一起删除
drop user studnet cascade;
--取别名 加public 所有的表都能发现 同义词
create public synonym e for scott.emp;
--删除别名 加public 的删除的时候也要加
drop synonym e
--索引是需要的那个字段才创建在那个字段上面 一般是跟在where后面
--创建索引
create index nname on scott.emp(sname);
create unique index uname on dept10(ename);
--反向键 123 --- 321 提高查询性能
create index rsal on dept10(sal) reverse;
create bitmap index bcomm on dept10(comm);
create index fname on dept10(lower(ename));
create index salcomm on dept10(sal, comm);
--查看已经创建的 index
select index_name, table_name from dba_indexes;
--视图描述用户可以访问的所有表上的索引
select index_name, table_name from all_indexes;
--USER视图描述用户所拥有的表上的索引
select index_name, table_name from user_indexes;
--重命名 索引
ALTER INDEX nname RENAME TO new_name;
--重建索引
ALTER INDEX nname REBUILD;
--合并索引,清除碎片
ALTER INDEX new_name COALESCE;
--删除索引
DROP INDEX new_name;