sql basic commands with examples pdf

Page 1

CLICKHERETO DOWNLOAD

Peoplearealsoreading:BestSQLCourses;BestSQLServerCertifications;SQLCertifications;BestSQLBooks;SQLUsingtheINSERTINTOstatement,we canaddnewdatatoatable.Chapters.ThisQuickReferencediscussesthefollowingfeaturesofSQLDeveloperCommand-Line(SQLcl):AlphabeticListof SQLclCommandsTorenameacolumnoratablewhenreturningresults,youcanusetheAScommandtosetanaliasforyouroutputsTheoutputshowsallthe employees’IDsandtheirrespectivesalesinthefirsthalfofUsingSUM()andGROUPBYThisqueryusestheaggregatefunctionSUM()withGROUPBYIn SQL,aggregatefunctionsworkongroupsofdata;forexample,SUM(sales)showsthetotalofallthevaluesinthesalescolumnA4SQLBasicsCheatSheet

Author:Subject:ThischeatsheetisaquickreferenceguidecontainingcommonlyusedSQLcommandsandsyntaxYou'lluseitprettymucheverytimeyouquery datawithSQLItallowsyoutodefinewhatdatayouwantyourquerytoreturnMySQListhelatestversionavailablenowWhatCanSQLdo?Keywords:SQL cheatsheet,SQLbasics,SQLsyntax,SQLguideCreatedDate/23/AMAbasicSQLcommandscheatsheetisusefulforquicklearning.StartingandLeaving SQLcl.LIMIT;AS.InSQLtheSELECTstatementistheworkhorsefortheseoperations.SELECTname.SELECT*.EnteringandExecutingCommands, MySQListhemostpopular,Oraclebacked,open-sourceStructuredQueryLanguageSQLcancreatenewtablesinadatabaseThisexampleselectsallcolumns fromthefilmstableandthenlimitstheresultstothefirsttenrowsConsidereachtupleoneaftertheother,eliminatingthosethatdonotsatisfytheWHEREclause SQLcanupdaterecordsinadatabase=,,>=,andSELECTisprobablythemostcommonly-usedSQLstatementRefertoAboutThisQuickReferenceFROM customers;BooleanconditionthatmustbeSELECTSEMANTICSFORRELATIONLogicalcomparisonoperatorstrueforanyretrievedtupleFormanyof themodernusesofdatabases,allyou’llneedtodowiththedatabaseistoselectsomesubsetofthevariablesand/orobservationsfromatable,andletsomeother programmanipulatethem.ThebasicSQLcommandgroupsareDataDefinitionLanguage,DataManipulationLanguage,DataControlLanguage,DataQuery Language,andDataTransferLanguageItisacomponentoftheLAMP[Linux–Apache–MySQL–PHP/Python/Perl]ApplicationStackSQLcaninsert recordsinadatabaseSQL*PlusListofUnsupportedCommandsandFeaturesVariousotherdatabase-drivenapplicationsalsoimplementitsqleBookSQL cancreatenewdatabasesChapterAND&OROperatorsAndtokeepthingsorganized,we’vegroupedtheSQLcommandlistintofivecorecategories:Data DefinitionLanguage(DDL),DataManipulationLanguage(DML),DataMySQLCommandsCheatSheetCREATEDATABASEdatabasename;USE databasename;DROPDATABASEdatabasename;SHOWDATABASES;DatabasesUsersandPrivilegesTablesUSER()CREATEUSER 'user'@'localhost';DROPUSER'user'@'host';GRANTprivilegesnamesONobjectTOuser;REVOKEprivilegesONprocedurallanguageextensiontoOracle SQLPro*C/C++Programmer'sGuideandPro*COBOLProgrammer'sGuidefordetaileddescriptionsofOracleembeddedSQLManyoftheexamplesinthis bookusethesampleschemas,whichareinstalledbydefaultwhenyouselecttheBasicInstallationoptionwithanOracleDatabaseinstallationForexample,inthe codebelow,we’reselectingacolumncallednamefromatablecalledcustomersFROMfilmsSQLcanretrievedatafromadatabaseChapterGettingstarted withSQLChapterALTERTABLEStartingUpandShuttingDownaDatabaseSQLcancreatestoredproceduresinadatabaseTolimitthenumberofrows, youcanusetheLIMITcommandSQLcandeleterecordsfromadatabaseSQLcanexecutequeriesagainstadatabaseLearningSQLeBook(PDF) DownloadthiseBookforfreeStartwiththerelationnamedintheFROMclauseItisaRelationalDatabaseManagementSystemHere’sabasicexampleadding anewusertotheuserstable:Thenifyouweretorerunthequerytoreturnalldatafromtheuser’stable,theresultssetwouldlooklikethis:Ofcourse,these examplesdemonstrateonlyaverysmallselectionofwhattheSQLlanguageisSELECT.

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.