资源描述:
《Oracle数据库-SQL学习.pdf》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1SQL2scott2.1emp1EMPNo.1EMPNONUMBER(4)2ENAMEVARCHAR2(10)3JOBVARCHAR2(9)4MGRNUMBER(4)5HIREDATEDATE6SALNUMBER(7,2)7COMMNUMBER(7,2)8DEPTNONUMBER(2)2.2deptdeptNo.1DEPTNONUMBER(2)2DNAMEVARCHAR2(14)3LOCVARCHAR2(13)2.3SALGRADESALGRADENo.1GRADENUMBER2LOSALNUMBE
2、R3HISALNUMBER2.4BONUS2BONUSNo.1ENAMEVARCHAR2(10)2JOBVARCHAR2(9)3SALNUMBER4COMMNUMBER33.11Oracle2sqlplusw3.212DISTINCT345Oracle4SQLSQL4.1SQLSQLStructuredQueryLanguageSQLANSISQL3SQLDMLDataManipulationLanguageDDLDataDefinitionLanguageDCLDataControlLanguage
3、4.2SELECT*
4、FROM;SELECT*FROMemp;SELECTempno,ename,jobFROMemp;4SELECTempno,ename,jobFROMemp;jobSELECTjobFROMemp;5DISTINCTSELECT{DISTINCT}*
5、FROM;SELECTDISTINCTempno,jobFROMemp;7369SMITHCLERK6Oracle
6、
7、'SELECT''
8、
9、empno
10、
11、''
12、
13、ename
14、
15、''
16、
17、jobFROMemp;SELECTename,s
18、al*12FROMemp;sal*12SELECTename,sal*12incomeFROMemp;+-*/74.3WHERESELECT{DISTINCT}*
19、FROM{WHERE(s)}1500sal>1500SELECT*FROMempWHEREsal>1500;commnullISNOTNULLSELECT*FROMempWHEREcommISNOTNULL;8commnullISNULLSELECT*FROMempWHEREcommISNULL;1500ANDSELECT*FROMempW
20、HEREsal>1500ANDcommISNOTNULL;1500ORSELECT*FROMempWHEREsal>1500ORcommISNOTNULL;9NOT1500SELECT*FROMempWHERENOT(sal>1500ANDcommISNOTNULL);15003000sal>1500sal<3000SELECT*FROMempWHEREsal>1500ANDsal<3000;SQLBETWEEN…AND….BETWEENANDBETWEEN…ANDSELECT*FROMempWHER
21、EsalBETWEEN1500AND3000;10BETWEEN…ANDsal>=1500ANDsal<=30001981198111~19811231'SELECT*FROMempWHEREhiredateBETWEEN'1-1-81'AND'31-12-81';BETWEEN…ANDsmithename='smith'SELECT*FROMempWHEREename='smith';smithOracleSELECT*FROMempWHEREename='SMITH';11736974997521
22、OR
23、-empno=7369ORempno=7499ORempno=7521SELECT*FROMempWHEREempno=7369ORempno=7499ORempno=7521;SQLININ(1,2,…..,n)NOTINNOTIN(1,2,…..,n)SELECT*FROMempWHEREempnoIN(7369,7499,7521);12736974997521SELECT*FROMempWHEREempnoNOTIN(7369,7499,7521);INSMITHALLENKINGSEL
24、ECT*FROMempWHEREenameIN('SMITH','ALLEN','KING');SELECT*FROMempWHEREenameIN('SMITH','ALLEN','KING','#$#$$##$');SQLLIKELIKELIKE13%_MSELECT*FROMempWHEREenameLIKE'_M%';MMSELECT*FROMempWHEREenameLIKE'%M%';LIKESELECT*FROMempWHEREenameL