SQL - Tutorialspoint

Transcription

SQLi

SQLAbout the TutorialSQL is a database computer language designed for the retrieval and management of datain a relational database. SQL stands for Structured Query Language.This tutorial will give you a quick start to SQL. It covers most of the topics required for abasic understanding of SQL and to get a feel of how it works.AudienceThis tutorial is prepared for beginners to help them understand the basic as well as theadvanced concepts related to SQL languages. This tutorial will give you enoughunderstanding on the various components of SQL along with suitable examples.PrerequisitesBefore you start practicing with various types of examples given in this tutorial, I amassuming that you are already aware about what a database is, especially the RDBMS andwhat is a computer programming language.Compile/Execute SQL ProgramsIf you are willing to compile and execute SQL programs with Oracle 11g RDBMS but youdon’t have a setup for the same, do not worry. Coding Ground is available on a high-enddedicated server giving you real programming experience. It is free and is available onlinefor everyone.Copyright & Disclaimer Copyright 2018 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I)Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republishany contents or a part of contents of this e-book in any manner without written consentof the publisher.We strive to update the contents of our website and tutorials as timely and as precisely aspossible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt.Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of ourwebsite or its contents including this tutorial. If you discover any errors on our website orin this tutorial, please notify us at contact@tutorialspoint.comi

SQLTable of ContentsAbout the Tutorial . iAudience . iPrerequisites . iCompile/Execute SQL Programs . iCopyright & Disclaimer . iTable of Contents . ii1.SQL Overview . 1What is SQL? . 1SQL Process . 2SQL Commands. 32.SQL RDBMS Concepts . 5What is RDBMS? . 5SQL Constraints . 6Data Integrity . 7Database Normalization . 7Database – First Normal Form (1NF) . 8Database – Second Normal Form (2NF) . 10Database – Third Normal Form (3NF) . 113.SQL RDBMS Databases . 14MySQL . 14MS SQL Server . 15ORACLE . 16MS ACCESS. 174.SQL – Syntax . 19Various Syntax in SQL . 195.SQL Data Types . 246.SQL – Operators . 28What is an Operator in SQL? . 28SQL Arithmetic Operators . 28Arithmetic Operators – Examples . 29SQL Comparison Operators . 30Comparison Operators – Examples . 31SQL Logical Operators . 34Logical Operators – Examples. 357.SQL – Expressions . 41Boolean Expressions . 41Numeric Expressions . 42Date Expressions . 438.SQL – CREATE Database . 459.SQL DROP or DELETE Database . 4610. SQL SELECT Database, USE Statement . 47ii

SQL11. SQL CREATE Table . 48SQL - Creating a Table from an Existing Table . 4912. SQL DROP or DELETE Table . 5113. SQL INSERT Query . 5314. SQL SELECT Query . 5615. SQL WHERE Clause . 5916. SQL AND & OR Conjunctive Operators . 62The AND Operator . 62The OR Operator . 6317. SQL UPDATE Query . 6618. SQL DELETE Query . 6919. SQL LIKE Clause . 7220. SQL TOP, LIMIT or ROWNUM Clause . 7621. SQL ORDER BY Clause . 7922. SQL Group By . 8223. SQL Distinct Keyword . 8624. SQL SORTING Results . 8925. SQL Constraints . 92SQL - NOT NULL Constraint . 92SQL - DEFAULT Constraint . 93SQL - UNIQUE Constraint . 94SQL Primary Key. 95SQL Foreign Key . 96SQL CHECK Constraint . 98SQL INDEX Constraint . 99Dropping Constraints . 101Integrity Constraints . 10126. SQL Using Joins . 102SQL - INNER JOIN . 103SQL LEFT JOIN . 105SQL - RIGHT JOIN . 107SQL FULL JOIN . 109SQL SELF JOIN . 111SQL CARTESIAN or CROSS JOIN . 11327. SQL UNIONS CLAUSE . 116The UNION ALL Clause . 119SQL INTERSECT Clause . 121SQL

SQL is a language to operate databases; it includes database creation, deletion, fetching rows, modifying rows, etc. SQL is an ANSI (American National Standards Institute) standard language, but there are many different versions of the SQL language.