|
上完1Z0-051第6章 (52-30)
上完1Z0-051第7章 (52-31)
上完1Z0-051第8章 (52-32)
上完1Z0-051第9章 (52-33)
上完1Z0-051第10章 (52-34)
上完1Z0-051第11章 (52-35)
2015-08-15a.sql
- select e.employee_id, d.department_name
- from employees e
- natural join departments d;
-
-
- select e.employee_id, d.department_name
- from employees e, departments d
- where e.department_id=d.department_id and
- e.manager_id=d.manager_id;
-
- select e.employee_id, d.department_name
- from employees e, departments d
- where e.department_id=d.department_id;
-
- select e.employee_id, d.department_name, department_id
- from employees e
- natural join departments d;
-
- select e.employee_id, d.department_name, d.department_id
- from employees e, departments d
- where e.department_id=d.department_id and
- e.manager_id=d.manager_id;
-
- ---
- select e.employee_id, d.department_name, department_id
- from employees e
- join departments d
- using (department_id, manager_id)
- where department_id > 60 and
- d.department_name ='Sales';
- ---
- SELECT e.employee_id, e.last_name, d.department_id,
- d.department_id, d.location_id
- FROM employees e JOIN departments d
- ON (e.department_id = d.department_id)
- and (e.department_id>100);
- SELECT e.employee_id, e.last_name, d.department_id,
- d.department_id, d.location_id
- FROM employees e ,departments d
- where (e.department_id = d.department_id);
- SELECT e.employee_id, e.last_name, d.department_id, l.state_province,
- d.department_id, d.location_id
- FROM employees e JOIN departments d
- ON (e.department_id = d.department_id)
- join locations l
- on (d.location_id=l.location_id);
- SELECT e.employee_id, e.last_name, d.department_id,
- d.department_id, d.location_id
- FROM employees e JOIN departments d
- ON (e.department_id = d.department_id)
- where (e.department_id>100);
-
- ---
-
- select e.last_name||' works for '||m.last_name
- from employees e , employees m
- where e.manager_id=m.employee_id
- and e.employee_id=101;
- ----
-
- select * from employees where employee_id=178;
-
- ---
-
-
- SELECT e.employee_id, e.last_name, d.department_id,
- d.department_id, d.location_id
- FROM employees e ,departments d
- where e.department_id = d.department_id(+) order by 1;
-
- select * from departments ;
-
- SELECT e.employee_id, e.last_name, d.department_id,
- d.department_id, d.location_id
- FROM employees e ,departments d
- where e.department_id(+) = d.department_id;
- SELECT e.employee_id, e.last_name,
- department_id, d.location_id
- FROM employees e right join departments d
- using (department_id);
-
-
- SELECT e.employee_id, e.last_name, d.department_id,
- d.department_id, d.location_id
- FROM employees e ,departments d
- where e.department_id = d.department_id(+)
- union
- SELECT e.employee_id, e.last_name, d.department_id,
- d.department_id, d.location_id
- FROM employees e ,departments d
- where e.department_id(+) = d.department_id;
- SELECT e.employee_id, e.last_name, d.department_id,
- d.department_id, d.location_id
- FROM employees e full outer join (departments d)
- on ( e.department_id = d.department_id) order by 1;
-
-
复制代码
2015-0815b.sql
- SELECT employee_id, last_name
- FROM employees
- WHERE salary > any
- (SELECT MIN(salary)
- FROM employees
- GROUP BY department_id);
-
-
- SELECT last_name, job_id
- FROM employees
- WHERE job_id =
- (SELECT job_id
- FROM employees
- WHERE last_name = 'Haas');
-
-
- SELECT * FROM departments
- WHERE NOT EXISTS
- (SELECT 1 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, job_id, department_id
- FROM employees outer
- WHERE not EXISTS ( SELECT 'X'
- FROM employees
- WHERE manager_id =
- outer.employee_id);
- select * from job_history order by 1,2;
-
- select * from employees where employee_id in (101,176,200) order by 1;
- SELECT employee_id, job_id "X",sysdate,null
- FROM employees where employee_id in (101,176,200)
- UNION all
- SELECT employee_id, job_id "Y" , start_date,'CCCC'
- FROM job_history where employee_id in (101,176,200) order by 1,3 ;
- create table t05109_a( a number default 999 );
- select * from user_tab_columns tc where tc.TABLE_NAME like 'T05109_%';
-
- create table t05109_b ( a number ) ;
- insert into t05109_a(a) values (default);
- select * from t05109_a;
- create table t05110( pic_name varchar2(20), pic blob ) ;
- select * from t05110;
- declare
- v_f bfile;
- v_b blob;
- v_filename varchar2(20) :='dawn.png';
- begin
- v_f :=bfilename('DIR1', v_filename);
- insert into t05110 values ( v_filename, empty_blob() ) return pic into v_b;
- DBMS_LOB.FILEOPEN (v_f, DBMS_LOB.FILE_READONLY);
- dbms_lob.loadfromfile(dest_lob => v_b,
- src_lob => v_f,
- amount =>dbms_lob.getlength(v_f));
- DBMS_LOB.FILECLOSE (v_f);
- commit;
- end;
- create table t05310_f( a interval year(3) to month ) ;
- insert into t05310_f values ( interval '100-1' year(3) to month ) ;
- select sysdate+a from t05310_f;
-
- create table t05310_g( a interval day(3) to second(3)) ;
-
- insert into t05310_g values ( interval '10 05:10:10.333' day(3) to second(3));
-
- select sysdate+a from t05310_g;
-
-
-
- create table t05110_nn ( a number constraint c1 not null );
-
- select * from user_constraints c where c.TABLE_NAME
- in ( 'T05110_NN','T05110_CHK', 'T05110_NN2' );
-
-
- create table t05110_chk( a number constraint c2 check( a >5 )) ;
-
- create table t05110_nn2 ( a number, constraint c3 check(a is not null ));
-
- create table clone1 as select * from t05110_nn;
-
- create table clone2 as select * from t05110_chk;
-
- create table clone3 as select * from t05110_nn2;
-
- select * from user_constraints c where c.TABLE_NAME like 'CLONE%';
-
-
- create table t05110_cons ( a number ) ;
-
- alter table t05110_cons add ( b number ) ;
- select * from user_constraints c where c.TABLE_NAME='T05110_CONS';
-
- alter table t05110_cons add constraint chk1 check ( a+ b=1) ;
-
- insert into t05110_cons values ( 0.4, 0.6) ;
-
- select * from t05110_cons;
-
- insert into t05110_cons values ( 0.4, 0.5) ;
-
- select * from user_constraints c where c.TABLE_NAME in ('TPARENT','TSON');
-
- select * from tparent;
-
- select * from tson;
-
- alter table tson drop constraint SYS_C0014929;
-
- alter table tson add constraint fk_tson
- foreign key (b) referencing tparent on delet;
-
- delete from tparent where a=1;
-
- select * from tson;
-
- create table t05110_u( a number ) ;
-
- select * from user_indexes i where i.TABLE_NAME='T05110_U';
-
- alter table t05110_u drop constraint uk_t05110_u;
- alter table t05110_u add constraint uk_t05110_u unique(a) ;
-
- insert into t05110_u values (1) ;
-
- select * from t05110_u;
-
- create index i05110_u on t05110_u(a) ;
-
- alter table t05110_u add constraint uk_t05110_u unique(a) enable novalidate ;
-
- select * from t05110_u;
-
- insert into t05110_u values (1) ;
-
- create table t05110_x( a number ) ;
-
- alter table t05110_x add constraint uk_t05110_x unique(a) disable validate ;
-
- insert into t05110_x values ( 2) ;
-
-
- create table t05110_y ( a number );
-
- create unique index i05110_y on t05110_y ( a);
- drop index i05110_y;
-
- alter table t05110_y add constraint uk_t05110_y unique(a) deferrable initially deferred ;
-
- select * from user_indexes i where i.TABLE_NAME='T05110_Y';
-
- alter table t05110_y modify constraint uk_t05110_y initially immediate;
-
-
-
- CREATE or replace VIEW empvu80
- AS SELECT employee_id, last_name, salary, department_id
- FROM employees
- WHERE department_id = 80 with check option ;
-
-
- select * from empvu80;
- update empvu80 set department_id = 80 where employee_id=146;
- create table t05111_a ( a number ) ;
- insert into t05111_a values ( 4) ;
- create or replace view v05111_a
- as select a/2 b from t05111_a;
-
- select * from t05111_a;
-
- delete from v05111_a;
- update v05111_a set b=1 ;
- select * from user_sequences s where s.SEQUENCE_NAME='SEQ2';
- create sequence seq1 ;
- create sequence seq2
- nocache ;
-
- alter sequence seq2 order ;
-
- create sequence seq3
- increment by -10
- start with 100
- maxvalue 100
- minvalue -100
- cycle;
-
-
-
-
复制代码
|
|