INTRODUCTION TO SQL


Sql is the main language which is used in all the databases to create database and access data from the database.
Here we are going to discuss sql,before getting into sql let find out:
what sql is?
Sql stands for “structure query language ”.sql is non procedural language used to access and manipulate databases.
From sql we can say what do we want from a database. I hope this definition gives you basic idea of sql
next we will see,
Meaning of word “QUERY”?
A “query ” is a question we ask the database .if the asked data is in the database then SQL retrive it.
Here we will see sub language of sql SQL components are sub language in sql
to create ,modify,maintain,and provide security to database.sql  divided into six sub language.
Data Query Language (DQL)   statement used to  retrive a data from a database . Some Example:
  • SELECT:-retrive data from the database.
Data Definition Language (DDL) statements are used to define the database structure or schema .Some Example:
  • CREATE:-to create object in the database.
  • ALTER:-alter the structure of the database.
  • DROP :- delete object from the database.
  • TRUNCATE:-romove all records from a table ,including all space allocated for the records are removed.
  • COMMENT:- add comment to the data dictionary.
  • RENAME:-rename an object.
Data Manipulation Language (DML) statements are used for managing data within schema objects.Some Example:
  • SELECT:-retrive data from the database.
  • INSERT:-insert data into table.
  • UPDATE:-update existing data within a table.
  • DELETE:-delete all records from a table ,the space for the record remain .
  • MERGE: -UPSERT operation (insert or update)
  • CALL:-call a PL/SQL or java subprogram.
  • EXPALIN PLAN:- explain access path to data.
  • LOCK TABLE:- control concurrency.
Data Control Language(DCL) statements are used to control the database like giving permission to access the database to user of database.Some Examples:
  • GRANT:-gives user access privilage to database.
  • REVOKE:-withdraw access privileges given with GRANT command
Transaction Control(TCL) statements are used to manage the changes made by DML statements.it allows user statements to be grouped together into logical transactions.
  • COMMIT:-save work done.
  • SAVE POINT:-identify a point in a transaction to which you can later roll back
  • ROLLBACK :-restore database to original since the last COMMIT
  • SET TRANSACTION: change transaction option like isolation level and what rollback segment
    to use
I am interested in hearing your feedback, so that I can improve my articles and learning resources for you.

Share

Did you enjoy reading this and found it useful? If so, please share it with your friends:

2 comments:

  1. it's very nice ,many fb user can learn basic information about sql...

    ReplyDelete
  2. What's the difference between a primary key and a unique key?

    Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a non-clustered index by default. Another major difference is that, primary key does not allow NULLs, but unique key allows one NULL only.

    What are user defined data types and when you should go for them?

    User defined data types let you extend the base SQL Server data types by providing a descriptive name, and format to the database. Take for example, in your database, there is a column called Flight_Num which appears in many tables. In all these tables it should be varchar(8). In this case you could create a user defined data type called Flight_num_type of varchar(8) and use it across all your tables.


    What type of Index will get created after executing the above statement?

    Non-clustered index. Important thing to note: By default a clustered index gets created on the primary key, unless specified otherwise.


    What is the maximum size of a row?

    8060 bytes. Do not be surprised with questions like 'What is the maximum number of columns per table'. Check out SQL Server books online for the page titled: "Maximum Capacity Specifications".

    ReplyDelete