Over View of SQL

SQL (Structured Query Language) is a special-purpose programming language designed for storing, manipulating and retrieving data stored in a Relational Database Management System (RDBMS).SQL consists of a data definition language and a data manipulation language. SQL became a standard of the American National Standards Institute (ANSI) in 1986 and of the International Organization for Standardization (ISO) in 1987. Since then, the standard has been enhanced several times with added features. Most Relational Database Management Systems like MS SQL Server, Microsoft Access, Oracle, MySQL, DB2, Sybase, PostgreSQL and Informix use SQL as a database querying language.
Different Products of RDMS are:

Oracle
Oracle Corporation
SQL Server 2000
Microsoft Corporation
DB2 UDB
IBM
My SQL
My SQL
Sybase
Sybase

                               In SQL we have standard commands to interact with Relational Database. Those commands are Create, Alter, Truncate, and Drop. These Commands can be classified into groups based on their nature.

1)     DDL - Data Definition Language
2)     DML- Data Manipulation Language
3)     DQL- Data Query Language
4)     DCL- Data Control Language
5)     TCL- Transaction Control Language

1)DDL - Data Definition Language: These Statements (Commands) are used to Create, Insert, Modify and Drop Database Objects.
Some Examples:
a)      Create: Create Statement is used to make a new database, table, index, or stored procedures.
By using Create Statement we are creating a table in Database. Tables are organized into rows and columns.
Syntax for Create Statement:
Create Table  tablename (Column Name1 data type(size), Column Name1 data type(size), Column Name2 data type(size), Column Name3 data type(size), ………);
Here:
§  The column name represents specify the names of the columns of the table.
§  The data type parameter represents which type of data the column can hold (e.g. varchar integer, date etc.).
§  The size parameter represents the maximum length of the column of the table.

Example for Create Statement:
 Create Table Employee (empid  int (20), First Name Varchar(50), Last Name Varchar(50), Deportment varchar(50), Address Varchar(50),City Varchar (50));

Table name is Employee
In this table empid column is represents int data type and it will hold an integer Value. Last Name, First Name, Deportment, Address and City columns are of type varchar and will hold characters, and the maximum length for these fields is 50 characters. 

The empty "Employee" table will now look like this:





empid
First Name
Last Name
Deportment
Address
City





























2)    DML- Data Manipulation Language: These Statements (Commands) are used to Insert, Update and Delete Database Objects. 
      3)  DQL- Data Query Language: These Statements (Commands) are used  Select Commands 
     4)  DCL- Data Control Language: These Statements (Commands) are used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it.
Examples: GRANT, REVOKE statements
5)   TCL- Transaction Control Language: These Statements (Commands) are used to manage different transactions occurring within a database.
Examples: COMMIT, ROLLBACK statements


No comments:

Post a Comment