Oracle 笔记
1. select + xxx + from + xxx //查询语句 xxx 表示一个表
Select * from + xxx // * 表示一个列表中所有的内容
类: 1)// select * from country
2)// select vLastName, vFirstName from externalcandidate
“--”表示单行注释
“/* ... */ ”表示多行注释
2. desc + xxx // 查看表的结构 recruit
desc externalcandidate
3. select cCountryCode "编号",cCountry "国家" from country; //把标题名字换了
4. select distinct cCity from externalcandidate
加了个distinct,表示没有重复的了,重复显示一个。如果是两列的话有两个都是重复的话,就保留一个
select distinct cCity,CState from college
5.运算符
and
or
not
|| 连接两个字符串,把两列的数据合到一起去了
如:select vLastName || vFirstName from externalcandidate
//把两列的数据合起来的标题名字换了
select vLastName || vFirstName "name" from externalcandidate
//把两列的数据合起来之间加一个点
select vLastName || '.' ||vFirstName "name" from externalcandidate
//把两列的数据合起来之间加一个字符串
select vLastName || 'von' ||vFirstName "name" from externalcandidate
6. //把列出的数据乘上5的结果是多少
select nAnnualsalary * 5 from Annualsalary
//where nAnnualsalary > 40000 加入的条件语句放在后面 表示大于40000的把它列出来
select nAnnualsalary from Annualsalary where nAnnualsalary > 40000
//通过条件查找特定的对象
select vLastName, vFirstName from externalcandidate where vLastName = 'King' ;
// 表示两者之间
select nAnnualsalary from Annualsalary where nAnnualsalary > 30000 and nAnnualsalary < 40000;
//表示两者之间 包括两者的界限 30000和40000
//where 。。。 between 。。。 and 。。。;
select nAnnualsalary from Annualsalary where nAnnualSalary between 30000 and 40000;
//查询具体个对象 where +与前面的对象一样+in ('。。。', '。。。' ,'。。。')
select vFirstName from externalcandidate where vFirstName in ('Carol', 'Catherine' ,'David')
//查找比较模糊的对象 where 。。。 like '。。。%'
select vFirstName from externalcandidate where vFirstName like 'Da%' ;
select vFirstName from externalcandidate where vFirstName like '%in%' ;
select vFirstName from externalcandidate where vFirstName like 'L_nda' ;//这里的下划线表示一个字符
7.作业
1. select vLastName || vFirstName "名字" ,cCity ,nTestScore from externalcandidate where cCity = 'New York City' and nTestScore > 60;
2. select cZip"邮编" ,cState || cCity || vAddress"地址", vLastName || vFirstName"姓名 ", nTestScore from externalcandidate where nTestScore > 60;
3. select distinct cEmployeeCode ,nMonthlySalary ,nReferralBonus from monthlysalary where (nMonthlySalary * 12 + nReferralBonus) > 30000;
///////////////////////////
//
1. where 。。。 is null;当什么为空的时候
select vFirstName,VlastName, cPhone from externalcandidate where vEmailid is null;
2. where .... is not null 当什么不为空的时候
select vFirstName,dInterviewDate from externalcandidate where dInterviewDate is not null
3.order by 。。。(asc)