STRUCTURED QUERY LANGUAGE – INTRODUCTION, COMMANDS

What is SQL?

The Structured Query Language (SQL) is a standard programming language to access and manipulate databases. SQL allows the user to create, retrieve, alter, and transfer information among databases. It is a language designed for managing and accessing data in Relational Data Base Management System (RDBMS).

How to create a Database?

To create a database, type the following command in the prompt:

CREATE DATABASE database_name;

Example:

If you want to create a database containing information about the students then you can type,

CREATE DATABASE student;

NOTE: Any name can be given as database_name. In my example, I have taken it as student

COMMANDS OF SQL

SQL commands are divided into 5 categories:

DDL – Data Definition Language

DML – Data Manipulation Language

DCL – Data Control Language

TCL -Transaction Control Language

DQL – Data Query Language

SQL commands under DDL are:
 
CREATE To create tables in the database.
ALTER Alters the structure of the database.
DROP Delete tables from database.
TRUNCATE Remove all records from a table, also release the space occupied by those records.
SQL commands under DML are:
INSERT Inserts data into a table.
UPDATE Updates the existing data within a table.
DELETE Delete all records from a table, but not the space occupied by them.
SQL commands under DCL are:
GRANT Grants permission to one or more users to perform specific tasks.
REVOKE Withdraws the access permission given by the GRANT statement.
SQL commands under TCL are:
COMMIT Saves any transaction into the database permanently.
ROLL BACK Restores the database to last COMMIT state.
SAVE POINT Temporarily save a transaction so that you can ROLL BACK.
SQL commands under DQL are:
SELECT It displays the records from the table.

Now let us see how to create a table using SQL commands.

You can create a table by using the CREATE TABLE command.

Syntax:

CREATE TABLE table_name

( column name <data type> (size),

column name <data type> (size),……

);

Example:
CREATE TABLE Student
       Admission_no integer,
       Name char(20),
       Age integer,
       Place char(10)
);

Leave a Comment

Your email address will not be published. Required fields are marked *