Contact Us:09993897203
Email: dstarenainfo@gmail.com
1st Branch: 121,Malviya Nagar,
New Market,Bhopal-462003
2nd Branch:146/7/2 Premium Center
Zone-1,MP Nagar
Bhopal-462011
Arrow Registration

SQL: Structured Query Language basics

Structured query language is abbreviated as SQL. SQL has three classification of command languages, they are :

  1. DDL: Data Definition Language
  2. DM: Data Manipulation Language
  3. TCL: Transaction Control Language

These three command languages help one to access SQL, using this one can create, update, manipulate, save and delete database tables.

DDL

DDL or Data Definition Language is used to describe the basics of a table, it defines the database tables. In this we have following commands:

  1. Create

This command is used to create a new table in a database.

Code:  >>create table tablename ();

>> create table employee ();

The above command creates a table with name employee but this table will have no attributes in it. To add attributes we have to write in this form;

>>create table employee (empname varchar2 (30),

empno number (4),

 empbranch varchar2 (10));

The above table is now created with  three attributes employee name as empname; employee number as empno;  employee branch as empbranch.

  1. Alter

Alter can be used in two ways:

  • To add a new column:

>>alter table employee add (empcity  varchar2(20));

This adds a new column to table employee named employee city as empcity.

  • For modification of existing table (empno  number(5));

>>alter table employee modify (empno  number(5));

This modifies table employee, it column empno with datatype number (4) to number (5).

  1. Drop

This helps in dropping the table or delete the whole table from the database.

>>drop employee;

  1. Desc

This command describes the table and its columns having its type and other attributes.

>>desc employee;

  1. Truncate

This command is used to delete all the data from the table;

>> truncate table employee; //this delete all the data from the table.

Stay connected to our next post we will be dealing with  DML And TCL.

Hit like if you found this post useful.

Leave a Reply

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

.