Oracle 데이터베이스 학습 사무, 무 거 운 제거, 빈 값 처리, 기본 연산 자 (5)

--  ,         ,     DML    ,commit,rollback(          ),savepoint(   )
update emp set EMPNO = 1234 where EMPNO=7369;
savepoint a;
rollback to a;--      a
rollback ;--    

--oracle     , Oracle          ,Oracle              ,       user_*、all_*、dba_*
select * from user_users;
select * from all_users;
select * from dba_users;
select * from user_source;
--oracle      ,      
select distinct job,deptno from emp;--                 ,      ,
--             ,                   , number>=2
--        
--    /        
alter session set nls_language = "SIMPLIFIED CHINESE";/AMERICAN;
--      
alter session set nls_date_format='YYYY/MM/DD';

--                ,          
create table test(id varchar2(10),name varchar(10));
insert into test values(1,'w');
insert into test values(2,'s');
insert into test values(1,'r');
insert into test values(3,'z');
select * from test;
create table A as select id,count(name) as num from test GROUP BY id ;
select * from A;
CREATE table B as select id from A a where a.num =1;
select * from B;
select * from test;
select B.id,test.name as name from B  LEFT JOIN  test  on  B.id = test.id;
--Oracle        
1.NVL(expr1,expr2)

  expr1 NULL,      expr2  ;

2.NVL2(expr1,expr2,expr3)

  expr1   NULL,      expr3  ;  NULL,  expr2  ;

3.NULLIF(expr1,expr2)

  expr1=expr2,  NULL;   ,           ;

4.COALSECE(expr1,expr2,expr3)

    NULL,     NULL;      NULL,      exprN;       ,         expr;

5.CASE 

SELECT cust_last_name,
   CASE credit_limit WHEN 100 THEN 'Low'
   WHEN 5000 THEN 'High'
   ELSE 'Medium' END
   FROM customers;

  C   case

6.DECODE

SELECT product_id,
       DECODE (warehouse_id, 1, 'Southlake', 
                             2, 'San Francisco', 
                             3, 'New Jersey', 
                             4, 'Seattle',
                                'Non-domestic') 
       "Location of inventory" FROM inventories
       WHERE product_id < 1775;


--Oracle      (+,-.*,/)
select empno,ename,sal*12 from emp;
--               ,              
create table studentI (
             id varchar2(10) primary key,
             name varchar2(10),
             age number(2,0) default 20       
);
insert into studentI values('1001','  ',default);
select * from studentI;

--      ,                  ,as       
select id,name "*name",age from studentI;
select id,name xingming,age from studentI;
select id,name as xingming,age from studentI;
--             ,       
select name||'    :'||age  as information from studentI;
select concat(name,age) as information from studentI;

--               ,          


--    where  
select * from studentI where age =20;

좋은 웹페이지 즐겨찾기