SQL Introduction

SQL tutorial provides basic and advanced concepts of SQL. Our SQL tutorial is designed for beginners and professionals.

SQL (Structured Query Language) is used to perform operations on the records stored in the database such as updating records, deleting records, creating and modifying tables, views, etc.

SQL is just a query language; it is not a database. To perform SQL queries, you need to install any database, for example, Oracle, MySQL, MongoDB, PostGre SQL, SQL Server, DB2, etc.


What is SQL

SQL stands for Structured Query Language.

It is designed for managing data in a relational database management system (RDBMS).

It is pronounced as S-Q-L or sometime See-Qwell.

SQL is a database language, it is used for database creation, deletion, fetching rows, and modifying rows, etc.

SQL is based on relational algebra and tuple relational calculus.

Why SQL is required

SQL is required:

To create new databases, tables and views

To insert records in a database

To update records in a database

To delete records from a database

To retrieve data from a database

Why SQL uses

We can query data from database.

It allows the user to describe the data.

It allows the user to define the data in the database and manipulate it when needed.

It allows the user to create and drop database and table.

It allows the user to create a view, stored procedure, function in a database.

It allows the user to set permission on tables, procedures, and views.

SQL Commands

The standard SQL commands to interact with relational databases are CREATE, SELECT, INSERT, UPDATE, DELETE and DROP. These commands can be classified into the following groups based on their nature


DML - Data Manipulation Language

1 SELECT:- Retrieves certain records from one or more tables.

2 INSERT:- Creates a record.

3 UPDATE:- Modifies records.

4 DELETE:- Deletes records.

DDL - Data Definition Language

1 CREATE :- Creates a new table, a view of a table, or other object in the database.

2 ALTER :- Modifies an existing database object, such as a table.

3 DROP :- Deletes an entire table, a view of a table or other objects in the database.

4 RENAME :- We may want to rename our table to give it a more relevant name. We can use ALTER TABLE to rename the name of table.

5 TRUNCATE :- A truncate SQL statement is used to remove all rows (complete data) from a table. It is similar to the DELETE statement with no WHERE clause.

6 COMMENT :- Comments are used to explain sections of SQL statements, or to prevent execution of SQL statements.

DCL - Data Control Language

1 GRANT Gives a privilege to user.

2 REVOKE Takes back privileges granted from user.

Transaction control

1 COMMIT :- Make changes done in transaction permanent.

2 ROLLBACK :- Rollbacks the state of database to the last commit point.

3 SAVEPOINT :- Use to specify a point in transaction to which later you can rollback



Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post