practice sql

Upload: vinay-kumar

Post on 30-Oct-2015

57 views

Category:

Documents


0 download

DESCRIPTION

sql

TRANSCRIPT

SQL> --select statementSQL> select * from dual;D - X SQL> --projection(vertical partitioning)SQL> select department_id,department_name from departments;DEPARTMENT_ID DEPARTMENT_NAME ------------- ------------------------------ 10 Administration 20 Marketing 30 Purchasing 40 Human Resources 50 Shipping 60 IT 70 Public Relations 80 Sales 90 Executive 100 Finance 110 Accounting DEPARTMENT_ID DEPARTMENT_NAME ------------- ------------------------------ 120 Treasury 130 Corporate Tax 140 Control And Credit 150 Shareholder Services 160 Benefits 170 Manufacturing 180 Construction 190 Contracting 200 Operations 210 IT Support 220 NOC DEPARTMENT_ID DEPARTMENT_NAME ------------- ------------------------------ 230 IT Helpdesk 240 Government Sales 250 Retail Sales 260 Recruiting 270 Payroll 27 rows selected.SQL> set pagesize 1000;SQL> set pagewidth 1000;SP2-0158: unknown SET option "pagewidth"SQL> help set SET --- Sets a system variable to alter the SQL*Plus environment settings for your current session, for example: - display width for data - turn on HTML formatting - enabling or disabling printing of column headings - number of lines per page In iSQL*Plus, you can also use the System Variables screen to set system variables. SET system_variable value where system_variable and value represent one of the following clauses: APPI[NFO]{OFF|ON|text} *NEWP[AGE] {1|n|NONE} ARRAY[SIZE] {15|n} NULL text AUTO[COMMIT] {OFF|ON|IMM[EDIATE]|n} NUMF[ORMAT] format AUTOP[RINT] {OFF|ON} NUM[WIDTH] {10|n} AUTORECOVERY {ON|OFF} PAGES[IZE] {24|n} AUTOT[RACE] {OFF|ON|TRACE[ONLY]} *PAU[SE] {OFF|ON|text} [EXP[LAIN]] [STAT[ISTICS]] RECSEP {WR[APPED] | BLO[CKTERMINATOR] {.|c} EA[CH]|OFF} CMDS[EP] {;|c|OFF|ON} RECSEPCHAR {_|c} COLSEP {_|text} SERVEROUT[PUT] {OFF|ON} COM[PATIBILITY] {V7|V8|NATIVE} [SIZE n] [FOR[MAT] CON[CAT] {.|c|OFF|ON} {WRA[PPED] | COPYC[OMMIT] {0|n} WOR[D_WRAPPED] | COPYTYPECHECK {OFF|ON} TRU[NCATED]}] DEF[INE] {&|c|OFF|ON} *SHIFT[INOUT] {VIS[IBLE] | DESCRIBE [DEPTH {1|n|ALL}] INV[ISIBLE]} [LINENUM {ON|OFF}] [INDENT {ON|OFF}] *SHOW[MODE] {OFF|ON} ECHO {OFF|ON} *SQLBL[ANKLINES] {ON|OFF} *EDITF[ILE] file_name[.ext] SQLC[ASE] {MIX[ED] | EMB[EDDED] {OFF|ON} LO[WER] | UP[PER]} ESC[APE] {\|c|OFF|ON} *SQLCO[NTINUE] {> | text} FEED[BACK] {6|n|OFF|ON} *SQLN[UMBER] {OFF|ON} FLAGGER {OFF|ENTRY|INTERMED[IATE]|FULL} SQLPLUSCOMPAT[IBILITY] {x.y[.z]} *FLU[SH] {OFF|ON} *SQLPRE[FIX] {#|c} HEA[DING] {OFF|ON} *SQLP[ROMPT] {SQL>|text} HEADS[EP] {||c|OFF|ON} SQLT[ERMINATOR] INSTANCE [instance_path|LOCAL] {;|c|OFF|ON} LIN[ESIZE] {80|n} ({150|n} iSQL*Plus) *SUF[FIX] {SQL|text} LOBOF[FSET] {n|1} TAB {OFF|ON} LOGSOURCE [pathname] TERM[OUT] {OFF|ON} LONG {80|n} TI[ME] {OFF|ON} LONGC[HUNKSIZE] {80|n} TIMI[NG] {OFF|ON} MARK[UP] HTML [ON|OFF] TRIM[OUT] {OFF|ON} [HEAD text] [BODY text] [TABLE text] TRIMS[POOL] {ON|OFF} [ENTMAP {ON|OFF}] UND[ERLINE] {-|c|ON|OFF} [SPOOL {ON|OFF}] VER[IFY] {OFF|ON} [PRE[FORMAT] {ON|OFF}] WRA[P] {OFF|ON} An asterisk (*) indicates the SET option is not supported in iSQL*Plus.SQL> --selection(horizontal partitioning)SQL> select * from employees where salary>8000;EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID ----------- -------------------- ------------------------- ------------------------- --------------- 100 Steven King SKING 515.123.4567 17-JUN-87 AD_PRES 101 Neena Kochhar NKOCHHAR 515.123.4568 21-SEP-89 AD_VP 102 Lex De Haan LDEHAAN 515.123.4569 13-JAN-93 AD_VP 103 Alexander Hunold AHUNOLD 590.423.4567 03-JAN-90 IT_PROG 108 Nancy Greenberg NGREENBE 515.124.4569 17-AUG-94 FI_MGR 109 Daniel Faviet DFAVIET 515.124.4169 16-AUG-94 FI_ACCOUN 110 John Chen JCHEN 515.124.4269 28-SEP-97 FI_ACCOUN 114 Den Raphaely DRAPHEAL 515.127.4561 07-DEC-94 PU_MAN 121 Adam Fripp AFRIPP 650.123.2234 10-APR-97 ST_MAN 145 John Russell JRUSSEL 011.44.1344.429268 01-OCT-96 SA_MAN 146 Karen Partners KPARTNER 011.44.1344.467268 05-JAN-97 SA_MAN 147 Alberto Errazuriz AERRAZUR 011.44.1344.429278 10-MAR-97 SA_MAN 148 Gerald Cambrault GCAMBRAU 011.44.1344.619268 15-OCT-99 SA_MAN 149 Eleni Zlotkey EZLOTKEY 011.44.1344.429018 29-JAN-00 SA_MAN 150 Peter Tucker PTUCKER 011.44.1344.129268 30-JAN-97 SA_REP 151 David Bernstein DBERNSTE 011.44.1344.345268 24-MAR-97 SA_REP 152 Peter Hall PHALL 011.44.1344.478968 20-AUG-97 SA_REP 156 Janette King JKING 011.44.1345.429268 30-JAN-96 SA_REP 157 Patrick Sully PSULLY 011.44.1345.929268 04-MAR-96 SA_REP 158 Allan McEwen AMCEWEN 011.44.1345.829268 01-AUG-96 SA_REP 162 Clara Vishney CVISHNEY 011.44.1346.129268 11-NOV-97 SA_REP 163 Danielle Greene DGREENE 011.44.1346.229268 19-MAR-99 SA_REP 168 Lisa Ozer LOZER 011.44.1343.929268 11-MAR-97 SA_REP 169 Harrison Bloom HBLOOM 011.44.1343.829268 23-MAR-98 SA_REP 170 Tayler Fox TFOX 011.44.1343.729268 24-JAN-98 SA_REP 174 Ellen Abel EABEL 011.44.1644.429267 11-MAY-96 SA_REP 175 Alyssa Hutton AHUTTON 011.44.1644.429266 19-MAR-97 SA_REP 176 Jonathon Taylor JTAYLOR 011.44.1644.429265 24-MAR-98 SA_REP 177 Jack Livingston JLIVINGS 011.44.1644.429264 23-APR-98 SA_REP 201 Michael Hartstein MHARTSTE 515.123.5555 17-FEB-96 MK_MAN 204 Hermann Baer HBAER 515.123.8888 07-JUN-94 PR_REP 205 Shelley Higgins SHIGGINS 515.123.8080 07-JUN-94 AC_MGR 206 William Gietz WGIETZ 515.123.8181 07-JUN-94 AC_ACCOUN33 rows selected.SQL> SQL> spool on;SQL> --arithmatic operatorSQL> select 10+20-5 from dual; 10+20-5---------- 25SQL> select 10+20-(5*8) from dual;10+20-(5*8)----------- -10SQL> --displaying null valuesSQL> select last_name from employees where commission_pct is null;LAST_NAME-------------------------KingKochharDe HaanHunoldErnstAustinPataballaLorentzGreenbergFavietChenSciarraUrmanPoppRaphaelyKhooBaidaTobiasHimuroColmenaresWeissFrippKauflingVollmanMourgosNayerMikkilineniLandryMarkleBissotAtkinsonMarlowOlsonMallinRogersGeePhiltankerLadwigStilesSeoPatelRajsDaviesMatosVargasTaylorFleaurSullivanGeoniSarchandBullDellingerCabrioChungDillyGatesPerkinsBellEverettMcCainJonesWalshFeeneyOConnellGrantWhalenHartsteinFayMavrisBaerHigginsGietz72 rows selected.SQL> -aliasesSP2-0042: unknown command "-aliases" - rest of line ignored.SQL> SQL> --aliasesSQL> select last_name,salary,commission_pct commission from employees where commission is not null;select last_name,salary,commission_pct commission from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name,salary,commission_pct as commission from employees where commission is not nulSQL> /select last_name,salary,commission_pct as commission from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name,salary,commission_pct "commission" from employees where commission is not nullSQL> /select last_name,salary,commission_pct "commission" from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name,salary,commission_pct as commission from employees where commission is not nulSQL> /select last_name,salary,commission_pct as commission from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name,salary,commission_pct commission from employees where commission is not nullSQL> /select last_name,salary,commission_pct commission from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name name,salary Salary,commission_pct commission from employees where commission iSQL> /select last_name name,salary Salary,commission_pct commission from employees where commission is not *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name name,salary Salary,commission_pct comm from employees where commission is not SQL> /select last_name name,salary Salary,commission_pct comm from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name name,salary Salary,commission_pct comm from employees where commission_pct is SQL> /NAME SALARY COMM------------------------- ---------- ----------Russell 14000 .4Partners 13500 .3Errazuriz 12000 .3Cambrault 11000 .3Zlotkey 10500 .2Tucker 10000 .3Bernstein 9500 .25Hall 9000 .25Olsen 8000 .2Cambrault 7500 .2Tuvault 7000 .15King 10000 .35Sully 9500 .35McEwen 9000 .35Smith 8000 .3Doran 7500 .3Sewall 7000 .25Vishney 10500 .25Greene 9500 .15Marvins 7200 .1Lee 6800 .1Ande 6400 .1Banda 6200 .1Ozer 11500 .25Bloom 10000 .2Fox 9600 .2Smith 7400 .15Bates 7300 .15Kumar 6100 .1Abel 11000 .3Hutton 8800 .25Taylor 8600 .2Livingston 8400 .2Grant 7000 .15Johnson 6200 .135 rows selected.SQL> edWrote file afiedt.buf 1* select last_name name,salary Salary,commission_pct comm from employees where commission_pct is SQL> select last_name,salary*12 "annual salary" from employees 2 ;LAST_NAME annual salary------------------------- -------------King 288000Kochhar 204000De Haan 204000Hunold 108000Ernst 72000Austin 57600Pataballa 57600Lorentz 50400Greenberg 144000Faviet 108000Chen 98400Sciarra 92400Urman 93600Popp 82800Raphaely 132000Khoo 37200Baida 34800Tobias 33600Himuro 31200Colmenares 30000Weiss 96000Fripp 98400Kaufling 94800Vollman 78000Mourgos 69600Nayer 38400Mikkilineni 32400Landry 28800Markle 26400Bissot 39600Atkinson 33600Marlow 30000Olson 25200Mallin 39600Rogers 34800Gee 28800Philtanker 26400Ladwig 43200Stiles 38400Seo 32400Patel 30000Rajs 42000Davies 37200Matos 31200Vargas 30000Russell 168000Partners 162000Errazuriz 144000Cambrault 132000Zlotkey 126000Tucker 120000Bernstein 114000Hall 108000Olsen 96000Cambrault 90000Tuvault 84000King 120000Sully 114000McEwen 108000Smith 96000Doran 90000Sewall 84000Vishney 126000Greene 114000Marvins 86400Lee 81600Ande 76800Banda 74400Ozer 138000Bloom 120000Fox 115200Smith 88800Bates 87600Kumar 73200Abel 132000Hutton 105600Taylor 103200Livingston 100800Grant 84000Johnson 74400Taylor 38400Fleaur 37200Sullivan 30000Geoni 33600Sarchand 50400Bull 49200Dellinger 40800Cabrio 36000Chung 45600Dilly 43200Gates 34800Perkins 30000Bell 48000Everett 46800McCain 38400Jones 33600Walsh 37200Feeney 36000OConnell 31200Grant 31200Whalen 52800Hartstein 156000Fay 72000Mavris 78000Baer 120000Higgins 144000Gietz 99600107 rows selected.SQL> --concatenation operatorSQL> select first_name||last_name NAME from employees;NAME---------------------------------------------StevenKingNeenaKochharLexDe HaanAlexanderHunoldBruceErnstDavidAustinValliPataballaDianaLorentzNancyGreenbergDanielFavietJohnChenIsmaelSciarraJose ManuelUrmanLuisPoppDenRaphaelyAlexanderKhooShelliBaidaSigalTobiasGuyHimuroKarenColmenaresMatthewWeissAdamFrippPayamKauflingShantaVollmanKevinMourgosJuliaNayerIreneMikkilineniJamesLandryStevenMarkleLauraBissotMozheAtkinsonJamesMarlowTJOlsonJasonMallinMichaelRogersKiGeeHazelPhiltankerRenskeLadwigStephenStilesJohnSeoJoshuaPatelTrennaRajsCurtisDaviesRandallMatosPeterVargasJohnRussellKarenPartnersAlbertoErrazurizGeraldCambraultEleniZlotkeyPeterTuckerDavidBernsteinPeterHallChristopherOlsenNanetteCambraultOliverTuvaultJanetteKingPatrickSullyAllanMcEwenLindseySmithLouiseDoranSarathSewallClaraVishneyDanielleGreeneMatteaMarvinsDavidLeeSundarAndeAmitBandaLisaOzerHarrisonBloomTaylerFoxWilliamSmithElizabethBatesSunditaKumarEllenAbelAlyssaHuttonJonathonTaylorJackLivingstonKimberelyGrantCharlesJohnsonWinstonTaylorJeanFleaurMarthaSullivanGirardGeoniNanditaSarchandAlexisBullJuliaDellingerAnthonyCabrioKellyChungJenniferDillyTimothyGatesRandallPerkinsSarahBellBritneyEverettSamuelMcCainVanceJonesAlanaWalshKevinFeeneyDonaldOConnellDouglasGrantJenniferWhalenMichaelHartsteinPatFaySusanMavrisHermannBaerShelleyHigginsWilliamGietz107 rows selected.SQL> --literal stringsSQL> select first_name||' '||last_name from employees;FIRST_NAME||''||LAST_NAME----------------------------------------------Steven KingNeena KochharLex De HaanAlexander HunoldBruce ErnstDavid AustinValli PataballaDiana LorentzNancy GreenbergDaniel FavietJohn ChenIsmael SciarraJose Manuel UrmanLuis PoppDen RaphaelyAlexander KhooShelli BaidaSigal TobiasGuy HimuroKaren ColmenaresMatthew WeissAdam FrippPayam KauflingShanta VollmanKevin MourgosJulia NayerIrene MikkilineniJames LandrySteven MarkleLaura BissotMozhe AtkinsonJames MarlowTJ OlsonJason MallinMichael RogersKi GeeHazel PhiltankerRenske LadwigStephen StilesJohn SeoJoshua PatelTrenna RajsCurtis DaviesRandall MatosPeter VargasJohn RussellKaren PartnersAlberto ErrazurizGerald CambraultEleni ZlotkeyPeter TuckerDavid BernsteinPeter HallChristopher OlsenNanette CambraultOliver TuvaultJanette KingPatrick SullyAllan McEwenLindsey SmithLouise DoranSarath SewallClara VishneyDanielle GreeneMattea MarvinsDavid LeeSundar AndeAmit BandaLisa OzerHarrison BloomTayler FoxWilliam SmithElizabeth BatesSundita KumarEllen AbelAlyssa HuttonJonathon TaylorJack LivingstonKimberely GrantCharles JohnsonWinston TaylorJean FleaurMartha SullivanGirard GeoniNandita SarchandAlexis BullJulia DellingerAnthony CabrioKelly ChungJennifer DillyTimothy GatesRandall PerkinsSarah BellBritney EverettSamuel McCainVance JonesAlana WalshKevin FeeneyDonald OConnellDouglas GrantJennifer WhalenMichael HartsteinPat FaySusan MavrisHermann BaerShelley HigginsWilliam Gietz107 rows selected.SQL> --eliminating duplicate rowsSQL> select distinct department_id from employees;DEPARTMENT_ID------------- 10 20 30 40 50 60 70 80 90 100 11012 rows selected.SQL> --describing structures of tableSQL> desc employees; Name Null? T --------------------------------------------------------------------------------------------------- EMPLOYEE_ID NOT NULL N FIRST_NAME V LAST_NAME NOT NULL V EMAIL NOT NULL V PHONE_NUMBER V HIRE_DATE NOT NULL D JOB_ID NOT NULL V SALARY N COMMISSION_PCT N MANAGER_ID N DEPARTMENT_ID NSQL> SELECT employee_id, last_name 2 sal x 12 ANNUAL SALARY 3 FROM employees;sal x 12 ANNUAL SALARY *ERROR at line 2:ORA-00923: FROM keyword not found where expectedSQL> edWrote file afiedt.buf 1 SELECT employee_id, last_name 2 sal * 12 ANNUAL SALARY 3* FROM employeesSQL> /sal * 12 ANNUAL SALARY *ERROR at line 2:ORA-00923: FROM keyword not found where expectedSQL> edWrote file afiedt.buf 1 SELECT employee_id, last_name, 2 sal * 12 ANNUAL SALARY 3* FROM employeesSQL> /sal * 12 ANNUAL SALARY *ERROR at line 2:ORA-00923: FROM keyword not found where expectedSQL> edWrote file afiedt.buf 1 SELECT employee_id, last_name, 2 salary * 12 "ANNUAL SALARY" 3* FROM employeesSQL> /EMPLOYEE_ID LAST_NAME ANNUAL SALARY----------- ------------------------- ------------- 100 King 288000 101 Kochhar 204000 102 De Haan 204000 103 Hunold 108000 104 Ernst 72000 105 Austin 57600 106 Pataballa 57600 107 Lorentz 50400 108 Greenberg 144000 109 Faviet 108000 110 Chen 98400 111 Sciarra 92400 112 Urman 93600 113 Popp 82800 114 Raphaely 132000 115 Khoo 37200 116 Baida 34800 117 Tobias 33600 118 Himuro 31200 119 Colmenares 30000 120 Weiss 96000 121 Fripp 98400 122 Kaufling 94800 123 Vollman 78000 124 Mourgos 69600 125 Nayer 38400 126 Mikkilineni 32400 127 Landry 28800 128 Markle 26400 129 Bissot 39600 130 Atkinson 33600 131 Marlow 30000 132 Olson 25200 133 Mallin 39600 134 Rogers 34800 135 Gee 28800 136 Philtanker 26400 137 Ladwig 43200 138 Stiles 38400 139 Seo 32400 140 Patel 30000 141 Rajs 42000 142 Davies 37200 143 Matos 31200 144 Vargas 30000 145 Russell 168000 146 Partners 162000 147 Errazuriz 144000 148 Cambrault 132000 149 Zlotkey 126000 150 Tucker 120000 151 Bernstein 114000 152 Hall 108000 153 Olsen 96000 154 Cambrault 90000 155 Tuvault 84000 156 King 120000 157 Sully 114000 158 McEwen 108000 159 Smith 96000 160 Doran 90000 161 Sewall 84000 162 Vishney 126000 163 Greene 114000 164 Marvins 86400 165 Lee 81600 166 Ande 76800 167 Banda 74400 168 Ozer 138000 169 Bloom 120000 170 Fox 115200 171 Smith 88800 172 Bates 87600 173 Kumar 73200 174 Abel 132000 175 Hutton 105600 176 Taylor 103200 177 Livingston 100800 178 Grant 84000 179 Johnson 74400 180 Taylor 38400 181 Fleaur 37200 182 Sullivan 30000 183 Geoni 33600 184 Sarchand 50400 185 Bull 49200 186 Dellinger 40800 187 Cabrio 36000 188 Chung 45600 189 Dilly 43200 190 Gates 34800 191 Perkins 30000 192 Bell 48000 193 Everett 46800 194 McCain 38400 195 Jones 33600 196 Walsh 37200 197 Feeney 36000 198 OConnell 31200 199 Grant 31200 200 Whalen 52800 201 Hartstein 156000 202 Fay 72000 203 Mavris 78000 204 Baer 120000 205 Higgins 144000 206 Gietz 99600107 rows selected.SQL> --practice 1SQL> --6:SQL> desc departments; Name Null? T --------------------------------------------------------------------------------------------------- DEPARTMENT_ID NOT NULL N DEPARTMENT_NAME NOT NULL V MANAGER_ID N LOCATION_ID NSQL> select * from departments;DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID------------- ------------------------------ ---------- ----------- 10 Administration 200 1700 20 Marketing 201 1800 30 Purchasing 114 1700 40 Human Resources 203 2400 50 Shipping 121 1500 60 IT 103 1400 70 Public Relations 204 2700 80 Sales 145 2500 90 Executive 100 1700 100 Finance 108 1700 110 Accounting 205 1700 120 Treasury 1700 130 Corporate Tax 1700 140 Control And Credit 1700 150 Shareholder Services 1700 160 Benefits 1700 170 Manufacturing 1700 180 Construction 1700 190 Contracting 1700 200 Operations 1700 210 IT Support 1700 220 NOC 1700 230 IT Helpdesk 1700 240 Government Sales 1700 250 Retail Sales 1700 260 Recruiting 1700 270 Payroll 170027 rows selected.SQL> --7:SQL> desc employees; Name Null? T --------------------------------------------------------------------------------------------------- EMPLOYEE_ID NOT NULL N FIRST_NAME V LAST_NAME NOT NULL V EMAIL NOT NULL V PHONE_NUMBER V HIRE_DATE NOT NULL D JOB_ID NOT NULL V SALARY N COMMISSION_PCT N MANAGER_ID N DEPARTMENT_ID NSQL> select last_name Name,job_code,hire_date "Start Date",employee_id from employees;select last_name Name,job_code,hire_date "Start Date",employee_id from employees *ERROR at line 1:ORA-00904: "JOB_CODE": invalid identifierSQL> edWrote file afiedt.buf 1* select employee_id,last_name Name,job_id,hire_date "Start Date" from employeesSQL> /EMPLOYEE_ID NAME JOB_ID Start Dat----------- ------------------------- ---------- --------- 100 King AD_PRES 17-JUN-87 101 Kochhar AD_VP 21-SEP-89 102 De Haan AD_VP 13-JAN-93 103 Hunold IT_PROG 03-JAN-90 104 Ernst IT_PROG 21-MAY-91 105 Austin IT_PROG 25-JUN-97 106 Pataballa IT_PROG 05-FEB-98 107 Lorentz IT_PROG 07-FEB-99 108 Greenberg FI_MGR 17-AUG-94 109 Faviet FI_ACCOUNT 16-AUG-94 110 Chen FI_ACCOUNT 28-SEP-97 111 Sciarra FI_ACCOUNT 30-SEP-97 112 Urman FI_ACCOUNT 07-MAR-98 113 Popp FI_ACCOUNT 07-DEC-99 114 Raphaely PU_MAN 07-DEC-94 115 Khoo PU_CLERK 18-MAY-95 116 Baida PU_CLERK 24-DEC-97 117 Tobias PU_CLERK 24-JUL-97 118 Himuro PU_CLERK 15-NOV-98 119 Colmenares PU_CLERK 10-AUG-99 120 Weiss ST_MAN 18-JUL-96 121 Fripp ST_MAN 10-APR-97 122 Kaufling ST_MAN 01-MAY-95 123 Vollman ST_MAN 10-OCT-97 124 Mourgos ST_MAN 16-NOV-99 125 Nayer ST_CLERK 16-JUL-97 126 Mikkilineni ST_CLERK 28-SEP-98 127 Landry ST_CLERK 14-JAN-99 128 Markle ST_CLERK 08-MAR-00 129 Bissot ST_CLERK 20-AUG-97 130 Atkinson ST_CLERK 30-OCT-97 131 Marlow ST_CLERK 16-FEB-97 132 Olson ST_CLERK 10-APR-99 133 Mallin ST_CLERK 14-JUN-96 134 Rogers ST_CLERK 26-AUG-98 135 Gee ST_CLERK 12-DEC-99 136 Philtanker ST_CLERK 06-FEB-00 137 Ladwig ST_CLERK 14-JUL-95 138 Stiles ST_CLERK 26-OCT-97 139 Seo ST_CLERK 12-FEB-98 140 Patel ST_CLERK 06-APR-98 141 Rajs ST_CLERK 17-OCT-95 142 Davies ST_CLERK 29-JAN-97 143 Matos ST_CLERK 15-MAR-98 144 Vargas ST_CLERK 09-JUL-98 145 Russell SA_MAN 01-OCT-96 146 Partners SA_MAN 05-JAN-97 147 Errazuriz SA_MAN 10-MAR-97 148 Cambrault SA_MAN 15-OCT-99 149 Zlotkey SA_MAN 29-JAN-00 150 Tucker SA_REP 30-JAN-97 151 Bernstein SA_REP 24-MAR-97 152 Hall SA_REP 20-AUG-97 153 Olsen SA_REP 30-MAR-98 154 Cambrault SA_REP 09-DEC-98 155 Tuvault SA_REP 23-NOV-99 156 King SA_REP 30-JAN-96 157 Sully SA_REP 04-MAR-96 158 McEwen SA_REP 01-AUG-96 159 Smith SA_REP 10-MAR-97 160 Doran SA_REP 15-DEC-97 161 Sewall SA_REP 03-NOV-98 162 Vishney SA_REP 11-NOV-97 163 Greene SA_REP 19-MAR-99 164 Marvins SA_REP 24-JAN-00 165 Lee SA_REP 23-FEB-00 166 Ande SA_REP 24-MAR-00 167 Banda SA_REP 21-APR-00 168 Ozer SA_REP 11-MAR-97 169 Bloom SA_REP 23-MAR-98 170 Fox SA_REP 24-JAN-98 171 Smith SA_REP 23-FEB-99 172 Bates SA_REP 24-MAR-99 173 Kumar SA_REP 21-APR-00 174 Abel SA_REP 11-MAY-96 175 Hutton SA_REP 19-MAR-97 176 Taylor SA_REP 24-MAR-98 177 Livingston SA_REP 23-APR-98 178 Grant SA_REP 24-MAY-99 179 Johnson SA_REP 04-JAN-00 180 Taylor SH_CLERK 24-JAN-98 181 Fleaur SH_CLERK 23-FEB-98 182 Sullivan SH_CLERK 21-JUN-99 183 Geoni SH_CLERK 03-FEB-00 184 Sarchand SH_CLERK 27-JAN-96 185 Bull SH_CLERK 20-FEB-97 186 Dellinger SH_CLERK 24-JUN-98 187 Cabrio SH_CLERK 07-FEB-99 188 Chung SH_CLERK 14-JUN-97 189 Dilly SH_CLERK 13-AUG-97 190 Gates SH_CLERK 11-JUL-98 191 Perkins SH_CLERK 19-DEC-99 192 Bell SH_CLERK 04-FEB-96 193 Everett SH_CLERK 03-MAR-97 194 McCain SH_CLERK 01-JUL-98 195 Jones SH_CLERK 17-MAR-99 196 Walsh SH_CLERK 24-APR-98 197 Feeney SH_CLERK 23-MAY-98 198 OConnell SH_CLERK 21-JUN-99 199 Grant SH_CLERK 13-JAN-00 200 Whalen AD_ASST 17-SEP-87 201 Hartstein MK_MAN 17-FEB-96 202 Fay MK_REP 17-AUG-97 203 Mavris HR_REP 07-JUN-94 204 Baer PR_REP 07-JUN-94 205 Higgins AC_MGR 07-JUN-94 206 Gietz AC_ACCOUNT 07-JUN-94107 rows selected.SQL>SQL> --selection(horizontal partitioning)SQL> select * from employees where salary>8000;EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID ----------- -------------------- ------------------------- ------------------------- --------------- 100 Steven King SKING 515.123.4567 17-JUN-87 AD_PRES 101 Neena Kochhar NKOCHHAR 515.123.4568 21-SEP-89 AD_VP 102 Lex De Haan LDEHAAN 515.123.4569 13-JAN-93 AD_VP 103 Alexander Hunold AHUNOLD 590.423.4567 03-JAN-90 IT_PROG 108 Nancy Greenberg NGREENBE 515.124.4569 17-AUG-94 FI_MGR 109 Daniel Faviet DFAVIET 515.124.4169 16-AUG-94 FI_ACCOUN 110 John Chen JCHEN 515.124.4269 28-SEP-97 FI_ACCOUN 114 Den Raphaely DRAPHEAL 515.127.4561 07-DEC-94 PU_MAN 121 Adam Fripp AFRIPP 650.123.2234 10-APR-97 ST_MAN 145 John Russell JRUSSEL 011.44.1344.429268 01-OCT-96 SA_MAN 146 Karen Partners KPARTNER 011.44.1344.467268 05-JAN-97 SA_MAN 147 Alberto Errazuriz AERRAZUR 011.44.1344.429278 10-MAR-97 SA_MAN 148 Gerald Cambrault GCAMBRAU 011.44.1344.619268 15-OCT-99 SA_MAN 149 Eleni Zlotkey EZLOTKEY 011.44.1344.429018 29-JAN-00 SA_MAN 150 Peter Tucker PTUCKER 011.44.1344.129268 30-JAN-97 SA_REP 151 David Bernstein DBERNSTE 011.44.1344.345268 24-MAR-97 SA_REP 152 Peter Hall PHALL 011.44.1344.478968 20-AUG-97 SA_REP 156 Janette King JKING 011.44.1345.429268 30-JAN-96 SA_REP 157 Patrick Sully PSULLY 011.44.1345.929268 04-MAR-96 SA_REP 158 Allan McEwen AMCEWEN 011.44.1345.829268 01-AUG-96 SA_REP 162 Clara Vishney CVISHNEY 011.44.1346.129268 11-NOV-97 SA_REP 163 Danielle Greene DGREENE 011.44.1346.229268 19-MAR-99 SA_REP 168 Lisa Ozer LOZER 011.44.1343.929268 11-MAR-97 SA_REP 169 Harrison Bloom HBLOOM 011.44.1343.829268 23-MAR-98 SA_REP 170 Tayler Fox TFOX 011.44.1343.729268 24-JAN-98 SA_REP 174 Ellen Abel EABEL 011.44.1644.429267 11-MAY-96 SA_REP 175 Alyssa Hutton AHUTTON 011.44.1644.429266 19-MAR-97 SA_REP 176 Jonathon Taylor JTAYLOR 011.44.1644.429265 24-MAR-98 SA_REP 177 Jack Livingston JLIVINGS 011.44.1644.429264 23-APR-98 SA_REP 201 Michael Hartstein MHARTSTE 515.123.5555 17-FEB-96 MK_MAN 204 Hermann Baer HBAER 515.123.8888 07-JUN-94 PR_REP 205 Shelley Higgins SHIGGINS 515.123.8080 07-JUN-94 AC_MGR 206 William Gietz WGIETZ 515.123.8181 07-JUN-94 AC_ACCOUN33 rows selected.SQL> SQL> spool on;SQL> --arithmatic operatorSQL> select 10+20-5 from dual; 10+20-5---------- 25SQL> select 10+20-(5*8) from dual;10+20-(5*8)----------- -10SQL> --displaying null valuesSQL> select last_name from employees where commission_pct is null;LAST_NAME-------------------------KingKochharDe HaanHunoldErnstAustinPataballaLorentzGreenbergFavietChenSciarraUrmanPoppRaphaelyKhooBaidaTobiasHimuroColmenaresWeissFrippKauflingVollmanMourgosNayerMikkilineniLandryMarkleBissotAtkinsonMarlowOlsonMallinRogersGeePhiltankerLadwigStilesSeoPatelRajsDaviesMatosVargasTaylorFleaurSullivanGeoniSarchandBullDellingerCabrioChungDillyGatesPerkinsBellEverettMcCainJonesWalshFeeneyOConnellGrantWhalenHartsteinFayMavrisBaerHigginsGietz72 rows selected.SQL> -aliasesSP2-0042: unknown command "-aliases" - rest of line ignored.SQL> SQL> --aliasesSQL> select last_name,salary,commission_pct commission from employees where commission is not null;select last_name,salary,commission_pct commission from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name,salary,commission_pct as commission from employees where commission is not nulSQL> /select last_name,salary,commission_pct as commission from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name,salary,commission_pct "commission" from employees where commission is not nullSQL> /select last_name,salary,commission_pct "commission" from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name,salary,commission_pct as commission from employees where commission is not nulSQL> /select last_name,salary,commission_pct as commission from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name,salary,commission_pct commission from employees where commission is not nullSQL> /select last_name,salary,commission_pct commission from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name name,salary Salary,commission_pct commission from employees where commission iSQL> /select last_name name,salary Salary,commission_pct commission from employees where commission is not *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name name,salary Salary,commission_pct comm from employees where commission is not SQL> /select last_name name,salary Salary,commission_pct comm from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name name,salary Salary,commission_pct comm from employees where commission_pct is SQL> /NAME SALARY COMM------------------------- ---------- ----------Russell 14000 .4Partners 13500 .3Errazuriz 12000 .3Cambrault 11000 .3Zlotkey 10500 .2Tucker 10000 .3Bernstein 9500 .25Hall 9000 .25Olsen 8000 .2Cambrault 7500 .2Tuvault 7000 .15King 10000 .35Sully 9500 .35McEwen 9000 .35Smith 8000 .3Doran 7500 .3Sewall 7000 .25Vishney 10500 .25Greene 9500 .15Marvins 7200 .1Lee 6800 .1Ande 6400 .1Banda 6200 .1Ozer 11500 .25Bloom 10000 .2Fox 9600 .2Smith 7400 .15Bates 7300 .15Kumar 6100 .1Abel 11000 .3Hutton 8800 .25Taylor 8600 .2Livingston 8400 .2Grant 7000 .15Johnson 6200 .135 rows selected.SQL> edWrote file afiedt.buf 1* select last_name name,salary Salary,commission_pct comm from employees where commission_pct is SQL> select last_name,salary*12 "annual salary" from employees 2 ;LAST_NAME annual salary------------------------- -------------King 288000Kochhar 204000De Haan 204000Hunold 108000Ernst 72000Austin 57600Pataballa 57600Lorentz 50400Greenberg 144000Faviet 108000Chen 98400Sciarra 92400Urman 93600Popp 82800Raphaely 132000Khoo 37200Baida 34800Tobias 33600Himuro 31200Colmenares 30000Weiss 96000Fripp 98400Kaufling 94800Vollman 78000Mourgos 69600Nayer 38400Mikkilineni 32400Landry 28800Markle 26400Bissot 39600Atkinson 33600Marlow 30000Olson 25200Mallin 39600Rogers 34800Gee 28800Philtanker 26400Ladwig 43200Stiles 38400Seo 32400Patel 30000Rajs 42000Davies 37200Matos 31200Vargas 30000Russell 168000Partners 162000Errazuriz 144000Cambrault 132000Zlotkey 126000Tucker 120000Bernstein 114000Hall 108000Olsen 96000Cambrault 90000Tuvault 84000King 120000Sully 114000McEwen 108000Smith 96000Doran 90000Sewall 84000Vishney 126000Greene 114000Marvins 86400Lee 81600Ande 76800Banda 74400Ozer 138000Bloom 120000Fox 115200Smith 88800Bates 87600Kumar 73200Abel 132000Hutton 105600Taylor 103200Livingston 100800Grant 84000Johnson 74400Taylor 38400Fleaur 37200Sullivan 30000Geoni 33600Sarchand 50400Bull 49200Dellinger 40800Cabrio 36000Chung 45600Dilly 43200Gates 34800Perkins 30000Bell 48000Everett 46800McCain 38400Jones 33600Walsh 37200Feeney 36000OConnell 31200Grant 31200Whalen 52800Hartstein 156000Fay 72000Mavris 78000Baer 120000Higgins 144000Gietz 99600107 rows selected.SQL> --concatenation operatorSQL> select first_name||last_name NAME from employees;NAME---------------------------------------------StevenKingNeenaKochharLexDe HaanAlexanderHunoldBruceErnstDavidAustinValliPataballaDianaLorentzNancyGreenbergDanielFavietJohnChenIsmaelSciarraJose ManuelUrmanLuisPoppDenRaphaelyAlexanderKhooShelliBaidaSigalTobiasGuyHimuroKarenColmenaresMatthewWeissAdamFrippPayamKauflingShantaVollmanKevinMourgosJuliaNayerIreneMikkilineniJamesLandryStevenMarkleLauraBissotMozheAtkinsonJamesMarlowTJOlsonJasonMallinMichaelRogersKiGeeHazelPhiltankerRenskeLadwigStephenStilesJohnSeoJoshuaPatelTrennaRajsCurtisDaviesRandallMatosPeterVargasJohnRussellKarenPartnersAlbertoErrazurizGeraldCambraultEleniZlotkeyPeterTuckerDavidBernsteinPeterHallChristopherOlsenNanetteCambraultOliverTuvaultJanetteKingPatrickSullyAllanMcEwenLindseySmithLouiseDoranSarathSewallClaraVishneyDanielleGreeneMatteaMarvinsDavidLeeSundarAndeAmitBandaLisaOzerHarrisonBloomTaylerFoxWilliamSmithElizabethBatesSunditaKumarEllenAbelAlyssaHuttonJonathonTaylorJackLivingstonKimberelyGrantCharlesJohnsonWinstonTaylorJeanFleaurMarthaSullivanGirardGeoniNanditaSarchandAlexisBullJuliaDellingerAnthonyCabrioKellyChungJenniferDillyTimothyGatesRandallPerkinsSarahBellBritneyEverettSamuelMcCainVanceJonesAlanaWalshKevinFeeneyDonaldOConnellDouglasGrantJenniferWhalenMichaelHartsteinPatFaySusanMavrisHermannBaerShelleyHigginsWilliamGietz107 rows selected.SQL> --literal stringsSQL> select first_name||' '||last_name from employees;FIRST_NAME||''||LAST_NAME----------------------------------------------Steven KingNeena KochharLex De HaanAlexander HunoldBruce ErnstDavid AustinValli PataballaDiana LorentzNancy GreenbergDaniel FavietJohn ChenIsmael SciarraJose Manuel UrmanLuis PoppDen RaphaelyAlexander KhooShelli BaidaSigal TobiasGuy HimuroKaren ColmenaresMatthew WeissAdam FrippPayam KauflingShanta VollmanKevin MourgosJulia NayerIrene MikkilineniJames LandrySteven MarkleLaura BissotMozhe AtkinsonJames MarlowTJ OlsonJason MallinMichael RogersKi GeeHazel PhiltankerRenske LadwigStephen StilesJohn SeoJoshua PatelTrenna RajsCurtis DaviesRandall MatosPeter VargasJohn RussellKaren PartnersAlberto ErrazurizGerald CambraultEleni ZlotkeyPeter TuckerDavid BernsteinPeter HallChristopher OlsenNanette CambraultOliver TuvaultJanette KingPatrick SullyAllan McEwenLindsey SmithLouise DoranSarath SewallClara VishneyDanielle GreeneMattea MarvinsDavid LeeSundar AndeAmit BandaLisa OzerHarrison BloomTayler FoxWilliam SmithElizabeth BatesSundita KumarEllen AbelAlyssa HuttonJonathon TaylorJack LivingstonKimberely GrantCharles JohnsonWinston TaylorJean FleaurMartha SullivanGirard GeoniNandita SarchandAlexis BullJulia DellingerAnthony CabrioKelly ChungJennifer DillyTimothy GatesRandall PerkinsSarah BellBritney EverettSamuel McCainVance JonesAlana WalshKevin FeeneyDonald OConnellDouglas GrantJennifer WhalenMichael HartsteinPat FaySusan MavrisHermann BaerShelley HigginsWilliam Gietz107 rows selected.SQL> --eliminating duplicate rowsSQL> select distinct department_id from employees;DEPARTMENT_ID------------- 10 20 30 40 50 60 70 80 90 100 11012 rows selected.SQL> --describing structures of tableSQL> desc employees; Name Null? T --------------------------------------------------------------------------------------------------- EMPLOYEE_ID NOT NULL N FIRST_NAME V LAST_NAME NOT NULL V EMAIL NOT NULL V PHONE_NUMBER V HIRE_DATE NOT NULL D JOB_ID NOT NULL V SALARY N COMMISSION_PCT N MANAGER_ID N DEPARTMENT_ID NSQL> SELECT employee_id, last_name 2 sal x 12 ANNUAL SALARY 3 FROM employees;sal x 12 ANNUAL SALARY *ERROR at line 2:ORA-00923: FROM keyword not found where expectedSQL> edWrote file afiedt.buf 1 SELECT employee_id, last_name 2 sal * 12 ANNUAL SALARY 3* FROM employeesSQL> /sal * 12 ANNUAL SALARY *ERROR at line 2:ORA-00923: FROM keyword not found where expectedSQL> edWrote file afiedt.buf 1 SELECT employee_id, last_name, 2 sal * 12 ANNUAL SALARY 3* FROM employeesSQL> /sal * 12 ANNUAL SALARY *ERROR at line 2:ORA-00923: FROM keyword not found where expectedSQL> edWrote file afiedt.buf 1 SELECT employee_id, last_name, 2 salary * 12 "ANNUAL SALARY" 3* FROM employeesSQL> /EMPLOYEE_ID LAST_NAME ANNUAL SALARY----------- ------------------------- ------------- 100 King 288000 101 Kochhar 204000 102 De Haan 204000 103 Hunold 108000 104 Ernst 72000 105 Austin 57600 106 Pataballa 57600 107 Lorentz 50400 108 Greenberg 144000 109 Faviet 108000 110 Chen 98400 111 Sciarra 92400 112 Urman 93600 113 Popp 82800 114 Raphaely 132000 115 Khoo 37200 116 Baida 34800 117 Tobias 33600 118 Himuro 31200 119 Colmenares 30000 120 Weiss 96000 121 Fripp 98400 122 Kaufling 94800 123 Vollman 78000 124 Mourgos 69600 125 Nayer 38400 126 Mikkilineni 32400 127 Landry 28800 128 Markle 26400 129 Bissot 39600 130 Atkinson 33600 131 Marlow 30000 132 Olson 25200 133 Mallin 39600 134 Rogers 34800 135 Gee 28800 136 Philtanker 26400 137 Ladwig 43200 138 Stiles 38400 139 Seo 32400 140 Patel 30000 141 Rajs 42000 142 Davies 37200 143 Matos 31200 144 Vargas 30000 145 Russell 168000 146 Partners 162000 147 Errazuriz 144000 148 Cambrault 132000 149 Zlotkey 126000 150 Tucker 120000 151 Bernstein 114000 152 Hall 108000 153 Olsen 96000 154 Cambrault 90000 155 Tuvault 84000 156 King 120000 157 Sully 114000 158 McEwen 108000 159 Smith 96000 160 Doran 90000 161 Sewall 84000 162 Vishney 126000 163 Greene 114000 164 Marvins 86400 165 Lee 81600 166 Ande 76800 167 Banda 74400 168 Ozer 138000 169 Bloom 120000 170 Fox 115200 171 Smith 88800 172 Bates 87600 173 Kumar 73200 174 Abel 132000 175 Hutton 105600 176 Taylor 103200 177 Livingston 100800 178 Grant 84000 179 Johnson 74400 180 Taylor 38400 181 Fleaur 37200 182 Sullivan 30000 183 Geoni 33600 184 Sarchand 50400 185 Bull 49200 186 Dellinger 40800 187 Cabrio 36000 188 Chung 45600 189 Dilly 43200 190 Gates 34800 191 Perkins 30000 192 Bell 48000 193 Everett 46800 194 McCain 38400 195 Jones 33600 196 Walsh 37200 197 Feeney 36000 198 OConnell 31200 199 Grant 31200 200 Whalen 52800 201 Hartstein 156000 202 Fay 72000 203 Mavris 78000 204 Baer 120000 205 Higgins 144000 206 Gietz 99600107 rows selected.SQL> --practice 1SQL> --6:SQL> desc departments; Name Null? T --------------------------------------------------------------------------------------------------- DEPARTMENT_ID NOT NULL N DEPARTMENT_NAME NOT NULL V MANAGER_ID N LOCATION_ID NSQL> select * from departments;DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID------------- ------------------------------ ---------- ----------- 10 Administration 200 1700 20 Marketing 201 1800 30 Purchasing 114 1700 40 Human Resources 203 2400 50 Shipping 121 1500 60 IT 103 1400 70 Public Relations 204 2700 80 Sales 145 2500 90 Executive 100 1700 100 Finance 108 1700 110 Accounting 205 1700 120 Treasury 1700 130 Corporate Tax 1700 140 Control And Credit 1700 150 Shareholder Services 1700 160 Benefits 1700 170 Manufacturing 1700 180 Construction 1700 190 Contracting 1700 200 Operations 1700 210 IT Support 1700 220 NOC 1700 230 IT Helpdesk 1700 240 Government Sales 1700 250 Retail Sales 1700 260 Recruiting 1700 270 Payroll 170027 rows selected.SQL> --7:SQL> desc employees; Name Null? T --------------------------------------------------------------------------------------------------- EMPLOYEE_ID NOT NULL N FIRST_NAME V LAST_NAME NOT NULL V EMAIL NOT NULL V PHONE_NUMBER V HIRE_DATE NOT NULL D JOB_ID NOT NULL V SALARY N COMMISSION_PCT N MANAGER_ID N DEPARTMENT_ID NSQL> select last_name Name,job_code,hire_date "Start Date",employee_id from employees;select last_name Name,job_code,hire_date "Start Date",employee_id from employees *ERROR at line 1:ORA-00904: "JOB_CODE": invalid identifierSQL> edWrote file afiedt.buf 1* select employee_id,last_name Name,job_id,hire_date "Start Date" from employeesSQL> /EMPLOYEE_ID NAME JOB_ID Start Dat----------- ------------------------- ---------- --------- 100 King AD_PRES 17-JUN-87 101 Kochhar AD_VP 21-SEP-89 102 De Haan AD_VP 13-JAN-93 103 Hunold IT_PROG 03-JAN-90 104 Ernst IT_PROG 21-MAY-91 105 Austin IT_PROG 25-JUN-97 106 Pataballa IT_PROG 05-FEB-98 107 Lorentz IT_PROG 07-FEB-99 108 Greenberg FI_MGR 17-AUG-94 109 Faviet FI_ACCOUNT 16-AUG-94 110 Chen FI_ACCOUNT 28-SEP-97 111 Sciarra FI_ACCOUNT 30-SEP-97 112 Urman FI_ACCOUNT 07-MAR-98 113 Popp FI_ACCOUNT 07-DEC-99 114 Raphaely PU_MAN 07-DEC-94 115 Khoo PU_CLERK 18-MAY-95 116 Baida PU_CLERK 24-DEC-97 117 Tobias PU_CLERK 24-JUL-97 118 Himuro PU_CLERK 15-NOV-98 119 Colmenares PU_CLERK 10-AUG-99 120 Weiss ST_MAN 18-JUL-96 121 Fripp ST_MAN 10-APR-97 122 Kaufling ST_MAN 01-MAY-95 123 Vollman ST_MAN 10-OCT-97 124 Mourgos ST_MAN 16-NOV-99 125 Nayer ST_CLERK 16-JUL-97 126 Mikkilineni ST_CLERK 28-SEP-98 127 Landry ST_CLERK 14-JAN-99 128 Markle ST_CLERK 08-MAR-00 129 Bissot ST_CLERK 20-AUG-97 130 Atkinson ST_CLERK 30-OCT-97 131 Marlow ST_CLERK 16-FEB-97 132 Olson ST_CLERK 10-APR-99 133 Mallin ST_CLERK 14-JUN-96 134 Rogers ST_CLERK 26-AUG-98 135 Gee ST_CLERK 12-DEC-99 136 Philtanker ST_CLERK 06-FEB-00 137 Ladwig ST_CLERK 14-JUL-95 138 Stiles ST_CLERK 26-OCT-97 139 Seo ST_CLERK 12-FEB-98 140 Patel ST_CLERK 06-APR-98 141 Rajs ST_CLERK 17-OCT-95 142 Davies ST_CLERK 29-JAN-97 143 Matos ST_CLERK 15-MAR-98 144 Vargas ST_CLERK 09-JUL-98 145 Russell SA_MAN 01-OCT-96 146 Partners SA_MAN 05-JAN-97 147 Errazuriz SA_MAN 10-MAR-97 148 Cambrault SA_MAN 15-OCT-99 149 Zlotkey SA_MAN 29-JAN-00 150 Tucker SA_REP 30-JAN-97 151 Bernstein SA_REP 24-MAR-97 152 Hall SA_REP 20-AUG-97 153 Olsen SA_REP 30-MAR-98 154 Cambrault SA_REP 09-DEC-98 155 Tuvault SA_REP 23-NOV-99 156 King SA_REP 30-JAN-96 157 Sully SA_REP 04-MAR-96 158 McEwen SA_REP 01-AUG-96 159 Smith SA_REP 10-MAR-97 160 Doran SA_REP 15-DEC-97 161 Sewall SA_REP 03-NOV-98 162 Vishney SA_REP 11-NOV-97 163 Greene SA_REP 19-MAR-99 164 Marvins SA_REP 24-JAN-00 165 Lee SA_REP 23-FEB-00 166 Ande SA_REP 24-MAR-00 167 Banda SA_REP 21-APR-00 168 Ozer SA_REP 11-MAR-97 169 Bloom SA_REP 23-MAR-98 170 Fox SA_REP 24-JAN-98 171 Smith SA_REP 23-FEB-99 172 Bates SA_REP 24-MAR-99 173 Kumar SA_REP 21-APR-00 174 Abel SA_REP 11-MAY-96 175 Hutton SA_REP 19-MAR-97 176 Taylor SA_REP 24-MAR-98 177 Livingston SA_REP 23-APR-98 178 Grant SA_REP 24-MAY-99 179 Johnson SA_REP 04-JAN-00 180 Taylor SH_CLERK 24-JAN-98 181 Fleaur SH_CLERK 23-FEB-98 182 Sullivan SH_CLERK 21-JUN-99 183 Geoni SH_CLERK 03-FEB-00 184 Sarchand SH_CLERK 27-JAN-96 185 Bull SH_CLERK 20-FEB-97 186 Dellinger SH_CLERK 24-JUN-98 187 Cabrio SH_CLERK 07-FEB-99 188 Chung SH_CLERK 14-JUN-97 189 Dilly SH_CLERK 13-AUG-97 190 Gates SH_CLERK 11-JUL-98 191 Perkins SH_CLERK 19-DEC-99 192 Bell SH_CLERK 04-FEB-96 193 Everett SH_CLERK 03-MAR-97 194 McCain SH_CLERK 01-JUL-98 195 Jones SH_CLERK 17-MAR-99 196 Walsh SH_CLERK 24-APR-98 197 Feeney SH_CLERK 23-MAY-98 198 OConnell SH_CLERK 21-JUN-99 199 Grant SH_CLERK 13-JAN-00 200 Whalen AD_ASST 17-SEP-87 201 Hartstein MK_MAN 17-FEB-96 202 Fay MK_REP 17-AUG-97 203 Mavris HR_REP 07-JUN-94 204 Baer PR_REP 07-JUN-94 205 Higgins AC_MGR 07-JUN-94 206 Gietz AC_ACCOUNT 07-JUN-94107 rows selected.SQL>SQL> --selection(horizontal partitioning)SQL> select * from employees where salary>8000;EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID ----------- -------------------- ------------------------- ------------------------- --------------- 100 Steven King SKING 515.123.4567 17-JUN-87 AD_PRES 101 Neena Kochhar NKOCHHAR 515.123.4568 21-SEP-89 AD_VP 102 Lex De Haan LDEHAAN 515.123.4569 13-JAN-93 AD_VP 103 Alexander Hunold AHUNOLD 590.423.4567 03-JAN-90 IT_PROG 108 Nancy Greenberg NGREENBE 515.124.4569 17-AUG-94 FI_MGR 109 Daniel Faviet DFAVIET 515.124.4169 16-AUG-94 FI_ACCOUN 110 John Chen JCHEN 515.124.4269 28-SEP-97 FI_ACCOUN 114 Den Raphaely DRAPHEAL 515.127.4561 07-DEC-94 PU_MAN 121 Adam Fripp AFRIPP 650.123.2234 10-APR-97 ST_MAN 145 John Russell JRUSSEL 011.44.1344.429268 01-OCT-96 SA_MAN 146 Karen Partners KPARTNER 011.44.1344.467268 05-JAN-97 SA_MAN 147 Alberto Errazuriz AERRAZUR 011.44.1344.429278 10-MAR-97 SA_MAN 148 Gerald Cambrault GCAMBRAU 011.44.1344.619268 15-OCT-99 SA_MAN 149 Eleni Zlotkey EZLOTKEY 011.44.1344.429018 29-JAN-00 SA_MAN 150 Peter Tucker PTUCKER 011.44.1344.129268 30-JAN-97 SA_REP 151 David Bernstein DBERNSTE 011.44.1344.345268 24-MAR-97 SA_REP 152 Peter Hall PHALL 011.44.1344.478968 20-AUG-97 SA_REP 156 Janette King JKING 011.44.1345.429268 30-JAN-96 SA_REP 157 Patrick Sully PSULLY 011.44.1345.929268 04-MAR-96 SA_REP 158 Allan McEwen AMCEWEN 011.44.1345.829268 01-AUG-96 SA_REP 162 Clara Vishney CVISHNEY 011.44.1346.129268 11-NOV-97 SA_REP 163 Danielle Greene DGREENE 011.44.1346.229268 19-MAR-99 SA_REP 168 Lisa Ozer LOZER 011.44.1343.929268 11-MAR-97 SA_REP 169 Harrison Bloom HBLOOM 011.44.1343.829268 23-MAR-98 SA_REP 170 Tayler Fox TFOX 011.44.1343.729268 24-JAN-98 SA_REP 174 Ellen Abel EABEL 011.44.1644.429267 11-MAY-96 SA_REP 175 Alyssa Hutton AHUTTON 011.44.1644.429266 19-MAR-97 SA_REP 176 Jonathon Taylor JTAYLOR 011.44.1644.429265 24-MAR-98 SA_REP 177 Jack Livingston JLIVINGS 011.44.1644.429264 23-APR-98 SA_REP 201 Michael Hartstein MHARTSTE 515.123.5555 17-FEB-96 MK_MAN 204 Hermann Baer HBAER 515.123.8888 07-JUN-94 PR_REP 205 Shelley Higgins SHIGGINS 515.123.8080 07-JUN-94 AC_MGR 206 William Gietz WGIETZ 515.123.8181 07-JUN-94 AC_ACCOUN33 rows selected.SQL> SQL> spool on;SQL> --arithmatic operatorSQL> select 10+20-5 from dual; 10+20-5---------- 25SQL> select 10+20-(5*8) from dual;10+20-(5*8)----------- -10SQL> --displaying null valuesSQL> select last_name from employees where commission_pct is null;LAST_NAME-------------------------KingKochharDe HaanHunoldErnstAustinPataballaLorentzGreenbergFavietChenSciarraUrmanPoppRaphaelyKhooBaidaTobiasHimuroColmenaresWeissFrippKauflingVollmanMourgosNayerMikkilineniLandryMarkleBissotAtkinsonMarlowOlsonMallinRogersGeePhiltankerLadwigStilesSeoPatelRajsDaviesMatosVargasTaylorFleaurSullivanGeoniSarchandBullDellingerCabrioChungDillyGatesPerkinsBellEverettMcCainJonesWalshFeeneyOConnellGrantWhalenHartsteinFayMavrisBaerHigginsGietz72 rows selected.SQL> -aliasesSP2-0042: unknown command "-aliases" - rest of line ignored.SQL> SQL> --aliasesSQL> select last_name,salary,commission_pct commission from employees where commission is not null;select last_name,salary,commission_pct commission from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name,salary,commission_pct as commission from employees where commission is not nulSQL> /select last_name,salary,commission_pct as commission from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name,salary,commission_pct "commission" from employees where commission is not nullSQL> /select last_name,salary,commission_pct "commission" from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name,salary,commission_pct as commission from employees where commission is not nulSQL> /select last_name,salary,commission_pct as commission from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name,salary,commission_pct commission from employees where commission is not nullSQL> /select last_name,salary,commission_pct commission from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name name,salary Salary,commission_pct commission from employees where commission iSQL> /select last_name name,salary Salary,commission_pct commission from employees where commission is not *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name name,salary Salary,commission_pct comm from employees where commission is not SQL> /select last_name name,salary Salary,commission_pct comm from employees where commission is not null *ERROR at line 1:ORA-00904: "COMMISSION": invalid identifierSQL> edWrote file afiedt.buf 1* select last_name name,salary Salary,commission_pct comm from employees where commission_pct is SQL> /NAME SALARY COMM------------------------- ---------- ----------Russell 14000 .4Partners 13500 .3Errazuriz 12000 .3Cambrault 11000 .3Zlotkey 10500 .2Tucker 10000 .3Bernstein 9500 .25Hall 9000 .25Olsen 8000 .2Cambrault 7500 .2Tuvault 7000 .15King 10000 .35Sully 9500 .35McEwen 9000 .35Smith 8000 .3Doran 7500 .3Sewall 7000 .25Vishney 10500 .25Greene 9500 .15Marvins 7200 .1Lee 6800 .1Ande 6400 .1Banda 6200 .1Ozer 11500 .25Bloom 10000 .2Fox 9600 .2Smith 7400 .15Bates 7300 .15Kumar 6100 .1Abel 11000 .3Hutton 8800 .25Taylor 8600 .2Livingston 8400 .2Grant 7000 .15Johnson 6200 .135 rows selected.SQL> edWrote file afiedt.buf 1* select last_name name,salary Salary,commission_pct comm from employees wher