标签:name rac 生成 组合索引 环境 creat 别名 独立 磁盘
数据库对象简介
CREATE USER test IDENTIFIED BY test; GRANT CONNECT , CREATE SYNONYM TO test; GRANT SELECT ON SCOTT.EMP TO test; GRANT DELETE ON SCOTT.EMP TO test; GRANT UPDATE ON SCOTT.EMP TO test;
CREATE SYNONYM staff FOR SCOTT.emp;
CREATE PUBLIC SYNONYM pub_emp FOR SCOTT.emp;
CREATE OR REPLACE PUBLIC SYNONYM pub_emp FOR SCOTT.emp;
DROP SYNONYM staff; DROP PUBLIC SYNONYM pub_emp;
序列
依次为:
序列案例
create table t_testseq ( id number primary key, name varchar2(10) NOT NULL );
create sequence seq_value Start with 1 Increment by 1;
访问序列
INSERT INTO t_testseq VALUES (seq_value.NEXTVAL, ‘tom‘) INSERT INTO t_testseq VALUES (seq_value.NEXTVAL, ‘jime‘);
SELECT seq_value.CURRVAL FROM dual;
更改和删除序列
ALTER SEQUENCE SEQ_VALUE MAXVALUE 5000 CYCLE;
DROP SEQUENCE SEQ_VALUE;
视图
select dept.deptno,dname,loc,empno,ename,job,mgr,hiredate from emp,dept where emp.deptno = dept.deptno and dname= ‘ SALES ‘;
--查看当前用户的系统权限 select * from user_sys_privs; --查看当前用户角色权限 select * from user_role_privs; --查看某个角色权限 select * from role_sys_privs where role =‘RESOURCE’; --创建视图 create view dept_emp as select dept.deptno,dname,loc,empno,ename,job,mgr,hiredate from emp,dept where emp.deptno = dept.deptno;
select * from dept_emp where dname= ‘ SALES ‘;
create view dept_emp_order as select dept.deptno,dname,loc,empno,ename,job,mgr,hiredate from emp,dept where emp.deptno = dept.deptno order by dept.deptno;
create view dept_sal_avg as select dname,avg(sal) avg_sal from dept,emp where dept.deptno = emp.deptno group by dname;
update dept_emp set ename = ‘TOM‘ WHERE empno = 7521;
Select ename from dept_emp where empno = 7521
Select ename from emp where empno = 7521
CREATE OR REPLACE [FORCE] VIEW view_name [(alias[, alias]...)] AS select_statement [WITH CHECK OPTION] [WITH READ ONLY];
DROP VIEW view_name;
管理索引
CREATE INDEX 索引名 ON 表名 (索引字段)
CREATE INDEX idx_ename ON emp (ename)
ALTER INDEX 索引名 REBUILD [REVERSE][NOREVERSE] ;
ALTER INDEX idx_ename REBUILD;
DROP INDEX 索引名;
DROP INDEX idx_ename;
测试索引
create table t_testseq ( id number, name varchar2(10) );
create sequence seq_value start with 1 increment by 1;
BEGIN FOR v_temp in 1..1000000 LOOP INSERT INTO t_testseq values(seq_value.nextval,’abcde’); END LOOP; END;
Set timing on; --sqlplus环境下设置
--常规查询 Select * from t_testseq where id = 28900; --创建索引,再查询 Create index idx_testseq_id on t_testseq(id);
Select * from t_testseq where id = 28900;
总结
标签:name rac 生成 组合索引 环境 creat 别名 独立 磁盘
原文地址:https://www.cnblogs.com/lzw123-/p/9796547.html