SQL
SQL was one of the first commercial languages to use Edgar F.Codd’s relational model. The model was described in his influential 1870 paper, “A Relational Model of Data for Large shared Data Banks”. Despite not entirely adhering to the relational model as described by Codd, it became the most widely used database language.
SQL(Structured Query Language) is a domain specific language and it is used to manage data in a relation database management(RDBMS), or relational data stream management system(RDSMS). It is specifically useful in handing structured data.
It is based upon relation algebra and tuple relational calculus. SQL consists of many types of statements, which may be called as sublanguages. Commonly a
->Data Query Language(DQL)
->Data Definition Language(DDL)
-> Data Control Language(DCL)
-> Data Manipulation Language(DML)
- SQL is essentially a Declarative language(4GL).
SQL data types:
The SQL standard defines three kinds of data types:
· predefined data types
· constructed types
· user-defined types.
Constructed types are one of ARRAY, MULTISET, REFERENCE or ROW. User-defined types are comparable to classes in object-oriented language with their own constructors, observers, mutators, methods, inheritance, overloading, overwriting, interfaces, and so on. Predefined data types are intrinsically supported by the implementation.
Predefined data types
->Character types
· Character (CHAR)
· Character varying (VARCHAR)
· Character large object (CLOB)
->National character types
· National character (NCHAR)
· National character varying (NCHAR VARYING)
· National character large object (NCLOB)
->Binary types
· Binary (BINARY)
Get DEEPAK.S’s stories in your inbox
Join Medium for free to get updates from this writer.
· Binary varying (VARBINARY)
· Binary large object (BLOB)
->Numeric types
· Exact numeric types (NUMERIC, DECIMAL, SMALLINT, INTEGER, BIGINT)
· Approximate numeric types (FLOAT, REAL, DOUBLE PRECISION)
· Decimal floating-point type (DECFLOAT)
· Datetime types (DATE, TIME, TIMESTAMP)
· Interval type (INTERVAL)
· Boolean
· XML
Database Tables
A database most often contains one or more tables. Each table is identified by a name (Eg. “Customers” or “Orders”). Tables contain records (rows) with data.
Note:
->Some database systems require a semicolon at the end of each SQL statement.
->Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.
Some of The Most Important SQL Commands
- SELECT — extracts data from a database
- UPDATE — updates data in a database
- DELETE — deletes data from a database
- INSERT INTO — inserts new data into a database
- CREATE DATABASE — creates a new database
- ALTER DATABASE — modifies a database
- CREATE TABLE — creates a new table
- ALTER TABLE — modifies a table
- DROP TABLE — deletes a table
- CREATE INDEX — creates an index (search key)
- DROP INDEX — deletes an index






