|
2014-10-23-plsql.sql
- SELECT last_name, job_id
- FROM employees
- WHERE job_id =
- (SELECT job_id
- FROM employees
- WHERE last_name = 'Haas');
- SELECT employee_id, last_name, job_id, salary
- FROM employees
- WHERE salary < any
- (SELECT salary
- FROM employees
- WHERE job_id = 'IT_PROG')
- AND job_id <> 'IT_PROG';
- SELECT * FROM departments
- WHERE NOT EXISTS
- (SELECT * FROM employees
- WHERE employees.department_id=departments.department_id);
-
-
- SELECT * FROM departments
- WHERE not EXISTS
- (SELECT 'X' FROM employees
- WHERE employees.department_id=departments.department_id);
-
-
- SELECT * FROM departments
- WHERE department_id not in
- (SELECT employees.department_id FROM employees
- WHERE employees.department_id=departments.department_id);
-
- select employee_id, last_name, salary
- from employees e
- where salary > ( select avg(salary) from employees a where a.department_id=e.department_id
- group by a.department_id ) ;
-
- select employee_id, last_name, salary
- from employees e , ( select avg(salary) avgsal , department_id from employees group by department_id) a
- where e.department_id=a.department_id
- and e.salary > a.avgsal;
- SELECT emp.last_name
- FROM employees emp
- WHERE emp.employee_id NOT IN
- (SELECT mgr.manager_id
- FROM employees mgr);
复制代码
2014-10-23-plsqlB.sql
- select * from job_history order by 1,2;
- select employee_id, job_id from employees where employee_id in (101,176,200);
- SELECT employee_id, job_id
- FROM employees
- minus
- SELECT employee_id , job_id
- FROM job_history ;
- SELECT employee_id , job_id xxx
- FROM job_history
- minus
- SELECT employee_id, job_id yyy
- FROM employees order by xxx;
复制代码
2014-10-23-plsqlC.sql
- create table t05109_a ( a number default 999) ;
- select * from user_tab_columns tc where tc.TABLE_NAME='T05109_A';
- insert into t05109_a values ( default);
- select * from t05109_a;
- alter table t05109_a modify ( a default 888 ) ;
- insert into t05109_a values ( default);
- insert into t05109_a values (&s_1);
- insert into t05109_a values (&&s_1);
复制代码
2014-10-23-plsqlD.sql
- alter table employees add ( department_name varchar2(30));
- select * from employees ;
- update employees e set department_name=(select department_name from departments d
- where e.department_id=d.department_id);
-
-
- create table t05109_b( a number , b varchar2(20)) ;
-
- create table t05109_c ( c number , d varchar2(20)) ;
-
- insert into t05109_b values ( 1 ,'A');
- insert into t05109_c values (2,'B');
- insert into t05109_b values (2,'B');
-
-
-
- select * from t05109_b;
-
- delete from t05109_b where a=( select c from t05109_c where t05109_c.d=t05109_b.b ) ;
-
- select bytes/1024/1024 from user_segments s where s.segment_name='TBIG';
-
- select * from v$session
- where sid in ( select blocking_session from v$session);
-
- select * from v$session where blocking_session is not null;
-
- alter system kill session '141,261' immediate;
复制代码
2014-10-23-plsqlE.sql
- select * from user_segments order by 1;
- select * from user_objects o where o.OBJECT_NAME='T05110';
- create table t05110_b( a varchar2(20), b blob ) ;
- select * from t05110_b;
- create table t05110_c ( a varchar2(20), b bfile ) ;
- insert into t05110_c values ( 'A', BFILENAME ('DIR1', 'a.jpg'));
- select * from t05110_c;
- select * from t05110_b;
- CREATE OR REPLACE PROCEDURE proc1 (p1 VARCHAR2 , p2 varchar2) AS
- v_f BFILE;
- v_b blob;
- BEGIN
- INSERT INTO t05110_b values(p1 ,EMPTY_BLOB ()) RETURN b into v_b;
- v_f := BFILENAME ('DIR1', p2);
- DBMS_LOB.FILEOPEN (v_f, DBMS_LOB.FILE_READONLY);
- DBMS_LOB.LOADFROMFILE (v_b, v_f,
- DBMS_LOB.GETLENGTH (v_f));
- DBMS_LOB.FILECLOSE (v_f);
- commit;
- end;
-
-
-
- begin
- proc1('A','a.jpg');
- end;
复制代码
|
|