Introduction to SQL

INTRODUCTION : -

  • SQL usually pronounced as “Sequel” stands for Structured Query Language.
  • SQL is the native language of the Oracle Server. It is the language used to communicate with the database. Again SQL consists of SQL statements and SQL*Plus commands. SQL statements are used to talk to the database. When you enter a SQL statement, it is stored in a part of the memory called the SQL Buffer and remains there until a new statement is entered. SQL*Plus is an Oracle tool that recognizes and submits 
  • SQL statements to the Oracle server for execution and contains its own command language.
Features of SQL:-

  • It is very easy to write, it can be used by all kinds of users with little or not programming experience.
  • It is a non-procedural language.
  • It reduces the amount of time required for creating and maintaining systems.
  • It is based on American National Standards Iinstitute (ANSI) standard SQL.
  • It manipulates data and tables definition in the database.
  • It is entered into SQL buffer on one or more lines.
  • It does not have a continuation character.
  • It cannot be abbreviated.
  • It uses a termination character to execute command immediately.
  • Uses functions to perform some formatting.

Features of SQL*Plus :-
  • Recognizes SQL statements and sends them to the server.
  • It accepts SQL input from files.
  • It provides a line editor for modifying SQL statements.
  • It controls environmental settings.
  • Accesses local and remote databases.
  • It doesn’t allow manipulation of values in the database.
  • It is entered one line at a time and is not stored in the SQL buffer.
  • Has a dash(-) as a continuation character if command exceed one line.
  • Doesn’t require any termination character, commands are executed immediately.
  • It uses commands to format data.
Advantages of SQL :-
  • SQL is a high level language that provides a greater degree of abstraction than procedural languages. It is designed so that the programmer can specify what data is needed but need not specify how to retrieves it.
  • Applications written in SQL can be easily ported across systems.
  • SQL as a language is independent of the way it is implemented internally.
  • The language even being simple and easy to learn can handle complex situations.
  • It is not just a query language, it can be used to define data structures, control access to the data and delete, insert, modify occurrences of the data.
  • The results to be expected are well defined i.e, there is no ambiguity about the way a query will interpret the data and produce the result.
Types of SQL :-

SQL can be classified on the basis of its various functionality, listed below.

  • Querying data.
  • Updating, inserting and deleting database objects.
  • Controlling access to the database.
  • Providing data integrity and consistency.
SQL statements are divided into following types.
  1.  Data Definition Language (DDL)
  2.  Data Manipulation Language (DML)
  3.  Transaction Control Lauguage (TCL)
  4.  Data Control Language (DCL)

    1)   Data Definition Language DDL) :-
The DDL commands enables you to perform :--
  • CREATE statement.
  • ALTER statement.
  • DROP statement.
  • RENAME statement.
  • TRUNCATE statement.
The objects that can be created, altered, dropped are :-
Cluster, Database, Database link, Function, Index, Package, Package body, Procedure, Rollback segment, Role, Sequence, Synonym, Table, User, View.

    2)  Data Manipulation Language (DML) :-

A DML command is used when we want to add, update or delete data in the database. A collection of DM statements that form a logical unit of work is called a transaction.

The DML commands are :-
  • INSERT statement.
  • UPDATE statement.
  • DELETE statement.

   3)  Transaction  Control Language (TCL) :-

As we know transaction is nothing but a set of inserts, updated and deletes (performed on the database) that form a logical unit of work. TCL is used to control these transactions i.e , whether or not a transaction should take place is controlled by TCL.

The TCL commands are :-
  • COMMIT statement.
  • ROLLBACK statement.
  • SAVEPOINT statement.

    4)  Data Control Language (DCL) :-

The DCL commands enable you to grant or revoke user privileges and roles.

The DCL commands are :-
  • GRANT statement.
  • REVOKE statement.
==================================================

No comments:

Post a Comment

Infolinks In Text Ads