Pages

Tuesday, November 8, 2016

Sql : Introduction

Introduction to SQL

SQL was one of the first commercial languages for Edgar F. Codd's relational model, as described in his influential 1970 paper, "A Relational Model of Data for Large Shared Data Banks." This became the foundation for the relational database system. This paper described a new way to structure data within a database and led to the relational database systems we use today. Despite not entirely adhering to the relational model as described by Codd, it became the most widely used database language.

What is a Relational Databases?

The Structured Query Language (SQL) is the language of databases. All modern relational databases, including Access, FileMaker Pro, Microsoft SQL Server and Oracle use SQL as their basic building block. In fact, it’s often the only way that you can truly interact with the database itself. All of the fancy graphical user interfaces that provide data entry and manipulation functionality are nothing more than SQL translators. They take the actions you perform graphically and convert them to SQL commands understood by the database.


What is a SQL?
  • SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database i.e. SQL is a programming language that allows interaction with databases.
  • SQL lets you access and manipulate databases. SQL is a language to:
    • Create databases and the objects within them.
    • Store data in those databases.
    • Change and analyze that data.
    • Get that data back out in reports, web pages, or virtually any other use imaginable.
  • According to ANSI (American National Standards Institute), it is the standard language for relational database management systems and is common to all major relational databases of all vendors worldwide.
  • SQL statements are used to perform tasks such as update data on a database, or retrieve data from a database.
  • Some common relational database management systems that use SQL are: Oracle, Sybase, Microsoft SQL Server, Access, Ingres, etc. Although most database systems use SQL, most of them also have their own additional proprietary extensions that are usually only used on their system.
  • The standard SQL commands such as "Select", "Insert", "Update", "Delete", "Create", and "Drop" can be used to accomplish almost everything that one needs to do with a database.
  • At its simplest level, SQL is all about—writing statements to create database objects, and then working with those objects to store and retrieve data.

SQL Scope

SQL consists of a data definition language, data manipulation language, and Data Control Language. The scope of SQL includes data insert, query, update and delete, schema creation and modification, and data access control.

What can SQL do?
  • SQL can execute queries against a database
  • SQL can retrieve data from a database
  • SQL can insert records in a database
  • SQL can update records in a database
  • SQL can delete records from a database
  • SQL can create new databases
  • SQL can create new tables in a database
  • SQL can create stored procedures in a database
  • SQL can create views in a database
  • SQL can set permissions on tables, procedures, and views

History Of SQL

The language, Structured English Query Language (SEQUEL) was developed by IBM Corporation, Inc., to use Codd's model. SEQUEL later became SQL (still pronounced "sequel"). In 1979, Relational Software, Inc. (now Oracle) introduced the first commercially available implementation of SQL.

Who created SQL?
  • Chamberlin is probably best known as co-inventor of SQL (Structured Query Language), the world's most widely used database language. Developed in the mid-1970s by Chamberlin and Raymond Boyce, SQL was the first commercially successful language for relational databases.

SQL was initially developed at IBM by Donald D. Chamberlin and Raymond F. Boyce in the early 1970s. This version, initially called SEQUEL (Structured English Query Language), was designed to manipulate and retrieve data stored in IBM's original quasi-relational database management system, System R, which a group at IBM San Jose Research Laboratory had developed during the 1970s. The acronym SEQUEL was later changed to SQL because "SEQUEL" was a trademark of the UK-based Hawker Siddeley aircraft company.

In the late 1970s, Relational Software, Inc. (now Oracle Corporation) saw the potential of the concepts described by Codd, Chamberlin, and Boyce, and developed their own SQL-based RDBMS with aspirations of selling it to the U.S. Navy, Central Intelligence Agency, and other U.S. government agencies. In June 1979, Relational Software, Inc. introduced the first commercially available implementation of SQL, Oracle V2 (Version2) for VAX computers.

SQL Syntax

SQL is followed by a unique set of rules and guidelines called Syntax. All the SQL statements are the combination of SQL syntax components and start with any of the keywords like SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW and all the statements end with a semicolon (;). Below is the simplest example to select column colA and column colB from a table named tableA.
select colA, colB from tableA;
What are the SQL Syntax Components?
The SQL syntax is subdivided into several components or syntax segments, including:
Fig 1.1 SQL Introduction - SQL Syntax Components
Fig 1.1 SQL Introduction - SQL Syntax Components
  • Clauses, which are constituent components of statements and queries. (In some cases, these are optional.)
  • Expressions, which can produce either scalar values, or tables consisting of columns and rows of data.
  • Predicates, which specify conditions that can be evaluated to SQL three-valued logic (3VL) (true/false/unknown) or Boolean truth values and are used to limit the effects of statements and queries, or to change program flow.
  • Queries, which retrieve the data based on specific criteria. This is an important element of SQL.
  • Statements, which may have a persistent effect on schemata and data, or may control transactions, program flow, connections, sessions, or diagnostics. SQL statements also include the semicolon (";") statement terminator. Though not required on every platform, it is defined as a standard part of the SQL grammar.
  • Insignificant whitespace is generally ignored in SQL statements and queries, making it easier to format SQL code for readability.

SQL Select Example

SQL SELECT statement is most frequently used statement and its used to fetch the data from a database table which returns data in the form of the result table. These result tables are called result-sets.

Fig 1.2 SQL Introduction - SQL SELECT Example
Fig 1.2 SQL Introduction - SQL SELECT Example

*Note- Important point to be noted is that SQL is case insensitive, which means SELECT and select have same meaning in SQL statements.

P.S.

Oracle Corporation’s implementation of the Structured Query Language, or SQL, is the core language at the foundation of all Oracle products and is arguably the most powerful and most significant computer language used in the world of government and business today.

No comments:

Post a Comment