zoukankan      html  css  js  c++  java
  • Oracle基本语句

    Oracle数据库基本语句:
    假设有表job,有4个字段JOB,SKILL,LS,ID都为varchar类型
    添加一行数据
    insert into job (JOB,SKILL,LS,ID) values ('行长','领导','1’,'1'); //为job表添加一条数据,其中job为‘行长’,skill为‘领导’,ls为’1‘,id为’1‘
    删除一行数据
    delete from job where ID = '1'; //删除job表中id为’1‘的所有数据
    去重查询
    select distinct name from job //查询表job中name字段的不重复数据

    修改一行数据
    update job set JOB=’' where ID=''; //将job表中id为''数据的job字段更新为''
    模糊查询
    select * from job where job like '%航空%'  //查询job表中job字段中含‘航空’的所有数据
    修改表名
    alter table job rename to work;   //将表job改名为work
    修改表中元素名
    alter table job rename column skill to sky; //将job表中的skill字段改为sky
    添加一个字段
    alter table job add (c varchar2(50))  //为job表添加一个varchar类型,长度为50,名称为c的字段
    删除一个字段
    alter table job drop(c)   //删除job表中名称为c的字段
    联合查询(其中nine_ans,nine_score为表名,type,score,objid,num,ans为字段名)
    select b.type, sum(b.score) as score
    from nine_ans t,nine_score b
    where t.objid='402881613a49410e013a4a8e
    7b89001e'
    and t.num=b.num
    and t.ans = b.seclection
    group by type)
    行转列 (使用pivot函数)
    select * from (select b.type, sum(b.score) as score
     
    from nine_ans t, nine_score b
    where t.objid = '402881613a49410e013a4a8e
    7b89001e'
    and 
    t.num = b.num
    and t.ans = b.seclection
    group 
    bytype)pivot(sum(score)for  type in  ('H' as H,'E'  as  E))
    用于替换字段值docode函数
    select decode(需要替换的字段名,需要替换的字段值,替换后的字段值,返回字段名) 
    as  更换字段名可以不更换
    select userid,name,sex,edu,tel,email,(select j.job from job j whereid = u.job) from userinfo u where usergroup in (select usergroupfrom admin where username like 'dm%')
  • 相关阅读:
    相对路径与绝对路径问题
    javaee自定义servlet的步骤
    Struts1.X与Spring集成——另外一种方案
    菜鸟也能学cocos2dx3.0 浅析刀塔传奇(下)
    JAVA之了解类载入器Classloader
    IOS 编程中引用第三方的方类库的方法及常见问题
    通过eclipse的egit插件提交提示Auth fail
    定时器0的方式1 定时器1的方式1 数码管和led
    MongoDB入门学习(四):MongoDB的索引
    J2EE--JDBC
  • 原文地址:https://www.cnblogs.com/MedivhQ/p/3801426.html
Copyright © 2011-2022 走看看