Partial preview of the text
Download Core SQL Commands You Should Master and more Study notes Computer Science in PDF only on Docsity!
BASIC SQL. © » What is GAL? > SQL . fey Styuctuved Quesy- Lonqvage- ig used for Aboving: ’ and vnaging, cata‘ velational chtatase Moragpnnent Austem CRDBMS) - ° SOL Commands + » SELECT — Extvouk chto dom database. The doo yetumned i, stored Sr a Yosult -tablo )» Calo the ‘ywersult — sek: QELECT Suntan ' Zerect Column 4 j column 2, - ~~ | FROM table — nome. , Hove » Column |; column Qy--y axe the Field roves of the tablo. uou cant te Aeloct dato fyorn* TL roant : to Collect alk the fields avai lablo &, the tablo use the Follow mg, Banton [Serect* FROM table — name SELECT Columns Zrample @ The dollowing S&L Atatement Glock the ‘Customey Name” , "City", ano a Courrtys” columns fom the Curtomer tablet [ecu Customey Name aa 7 Countyy, ‘From Customers.) + DPDATE Updotes dato fn a database The “UPDATE” Stotement ig wed to modify. the existing, vwecords tn a table. UPDATE. Sunton - UpDATE _ tablo _name seT Column 4d =Vale 1) Column 2 = Value 2y~ = WHERE Condition = —| gémomple :- UPDATE “Customey ZET. Contact Name = ‘Kanth’ City = Foank fut The CREATE DATABASE’ Wotement i¢ wal 4o (veate A new aL Potato. Syntam : , CREATE DAINBASE databae. none ; | CREATE PAIPRASE tout DB: | The “ALTER TABLE” statement “4g wed 4 Odd ) detete , ov redify Columns Crus bing, table» Ard alio wed toad ® —________@] INSERT INTO table-nane | VALDES (Value ty Value 2 Value 3); snample t- INSERT INTO Cuntorneré Castorney Rane) Contact Nome , Pdayvess , chy Hostal Codo ) CountyyyS VALVES (kanth’ , “Tom B" , \ekagpngy, “Stenenger! Suo0e *, ‘Neways ; 4 * CREATE DATABASE Create, a new Databore * ALTER TABLE Makifies a table — th an ce and dywpe \arviour tonstyaints on ewisting: +ablo- ALTER TABLE - ADD COLUNN- AIG TABLE fallo narva PPD -COlumn ~Mame data type EVO le +- PLTER. TABLE Customey APD EMATL \a@rchay (255)| DROP CouumMnN ° ALTER TABLE table rane “PROP Column Coumn Mame ; soample :- ALTER TABLE . Customers PROP COlLumP Email ° CREATE € TPBLE ; Groote’ O Now table The “CREATE TABLE" tntoment Ps Used to Crvoate GA Nes tabla tn Potaboie- Synto:- C RE Fire TABLE table. ame | (Cowrnn 4 cedatupe » | Column 2 chtatype, Column % datatype, | =); ave just wed tO spool up arches Ov GOwnios« Syntarn :— CREPTE TNDEX Aviex hare ON table — name CColumn 1, Column, > ~ ~\* EVOMPLE i Create Enpex idx _ last rave lon Feces Clout Nave. , Fivet Name) ; » DROP INDE * Detetes on Tnden_ The “DROP “TINDER” Atatement (S LL +4o delete an erden in a table. ALTER TRIBLE fable. rome | DROP TENDEX inden — Name 5