SQL Commands for Data Analysis

Home/SQL/SQL Commands for Data Analysis

SQL Commands will help Analyst to create database,creating new tables and views, update or deleting the existing data. SQL commands help to fetch the data from the database and format it to required standards and summarize to perform analysis.



50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates

SQL Data Manipulation Language – DML Commands

The Data Manipulation Language (DML) is used to insert and modify database information.
Different DML statements includes:

–INSERT: to add records into the table
–UPDATE: to change column value in the table
–DELETE: to remove rows from the table


SQL INSERT statement allows to insert single or multiple records into the tale.


[code language=”sql”] INSERT INTO table
(value-1, value-2, … value-n);


The following example insert a new record into Employee table,[code language=”sql”] INSERT INTO Employee(EID, Department, Name, Salary)
VALUES( 11,’HR’, ‘MICHAEL’,35000);


UPDATE QUERY is used to update existing records in the table.


[code language=”sql”] UPDATE table SET column1=value1,column2=value2… WHERE condition;


The following example update the Mike’s salary to 35000 in the Employee table,[code language=”sql”] UPDATE Employee SET Salary= 35000 WHERE Name = ‘Mike’;


DELETE QUERY is used to delete selected rows,or all rows from the table.


[code language=”sql”] DELETE from table WHERE condition;


The following example dlete the record where EID equals to 10 from the Employee table,[code language=”sql”] DELETE from Employee WHERE EID=10;

SQL Data Definition Language – DDL commands

The Data Definition Language (DDL) is used to create and destroy databases and database objects.

These commands are:
–CREATE: to create a new data structure.
–ALTER: to change an existing data structure.
–DROP: to remove an entire data structure.
–TRUNCATE : to remove all rows from table.
–RENAME : to rename existing table.


SQL command that adds a new table or View to an SQL database. Tables are a basic unit of organization and storage of data in SQL.

Syntax:[code lanuage=”sql”] CREATE TABLE <table_name> (
<column_name1> <datatype1> <constraint1>
<column_name2> <datatype2> <constraint2>
) ;


SQL command can be used to add, modify, or drop a column from the existing table or to rename a table.

Syntax:[code lanuage=”sql”] Alter table <table name> add <column name><data type>;


The SQL command that removes the entire table.

Syntax:[code lanuage=”sql”] Drop <table name>;

Note: Before table drop must remove the dependent constraints


The SQL command that removes the entire table.

Syntax:[code lanuage=”sql”] TRUNCATE table <table name>;


The SQL command that removes the entire table.

Syntax:[code lanuage=”sql”]

ALTER TABLE table_name RENAME TO new_table_name;

SQL Data Control Language – DCL commands

Data Control Language provides database administrators with the ability to grant users database permissions, revoke permissions previously granted .

Twp types of DCL commands are:Grant and Revoke.


To allow specified users to perform specified tasks.[code language=”sql”] SYNTAX:-GRANT [privilege]ON [object]TO [user][WITH GRANT OPTION]


Removes user access rights or privileges to the database objects.[code language=”sql”] REVOKE [GRANT OPTION FOR] [permission]ON [object]FROM [user]

SQL Transaction Control Language – TCL commands

SQL Transaction Control Language commands are used for managing changes affecting the data.

These commands are COMMIT, ROLLBACK and SAVEPOINT.


Save or enable DML changes to the database.

Syntax:[code language=”sql”] COMMIT;


To undo DML changes till in a transaction.

Syntax:[code language=”sql”] ROLLBACK SavePoint-Name;


To divide a transaction.

Syntax:[code language=”sql”] SAVEPOINT SavePoint-Name;

By |February 13th, 2013|SQL|1 Comment

About the Author:

PNRao is a passionate business analyst and having close to 10 years of experience in Data Mining, Data Analysis and Application Development. This blog is his passion to learn new skills and share his knowledge to make you expertise in Data Analysis (Excel, VBA, SQL, SAS, Statistical Methods, Market Research Methodologies and Data Analysis Techniques).

One Comment

  1. Sanjay gupta April 5, 2016 at 9:38 PM - Reply

    Hello i want to use DCL : Grant And Revoke In Sql Server 2012, How Can I Use It tell Me….

Leave A Comment

Related pages

what is dml and ddl in sql servercreating pivot charts in excel 2010how to password protect a spreadsheetvba combo boxhow to hide and unhide columns in excel 2007excel template project timelineremove blank rows from exceltutorial excel vlookupexcel 2013 pivot table wizardusing vlookup function in excelhow to hide unhide rows in excelusing sql in vbaabsolute value vbavba internetexplorer.applicationmicrosoft excel checkboxexcel charts examplesexcel hide buttonproject delivery plan templateopen and activate workbook vbadelete unwanted rows in exceldeleting cells in excelvba pivot table refreshchanging rows to columns in exceldelete vbasumif on excelcreate checkbox in excelcase syntax vbaexcel temp folderformat excel vbavba excel delete sheetcombine data from multiple worksheets into oneexcel data entry form template excel 20072014 calendar template excelactivex control exampleado recordset openvba loopexcel vba userform exampleshow to insert macros in excelexcel using vbaselect sheet excel vbacombobox vba excelunique records in excelvlookups on excelvbscript excel.applicationsurface chart exceladvanced filter criteria rangeexcel 2007 vba macro programmingexcel remove duplicate rowvba application.getsaveasfilenamehow to use match function in excelabout excel macrosuses of macro in excelexport excel to access vbavba choosesql tutorial for beginners with examples pptwhat is v lookup in exceldynamic range vbavba input message boxvba array excelddl dml statementsexcel macro matchlock excel sheet for editingdeleting rows in excelexcel vlookup offsetddl dml dcl tcl commands sql servervba activate sheetdir function in vbadelete doubles in excelexcel sorting numbersvba subroutinessumif in excelexcel ascending ordercapacity planning excel templatehow to get developer tab in excel 2013ms excel password protecthow do you create a macro in excel 2010how do you insert a row in excelexcel sumif examplesvba open file dialogexcel 2003 calendar template