What is basic SELECT statement?

SELECT Statement A SELECT statement retrieves data from the database. With SELECT statement PROJECTION, SELECTION and JOIN can be performed on database tables. As data in relational database is stored in TABLES. TABLE has ROW and COLUMN structure. With SELECT statement all rows and all columns can be retrieved, this is known as PROJECTION. But, if rows and columns are retrieved on the basis of some condition, it is known as SELECTION. And suppose if some information is needed and that is stored in two or more different tables but are related, use JOINS to retrieve it from two or more tables. In SQL, basic SELECT statements are as follows: SELECT  * FROM  [ table_name ] ; SELECT   [ column1 ] ,  [ column2 ] ,  [ column3 ] ,   .....   FROM   [ table_name ] ; SELECT and FROM are known as clauses.  SELECT clause allows to specify columns to be selected from the database table.  FROM clause allows to specify table name that has those column to be s

What are different SQL statements?

SQL Statements

Basically there are three types of SQL statements:

1. DDL  - Data Definition Language
2. DML - Data Manipulation Language
3. DCL  - Data Control Language 

1) Data Definition Language:

It is used to define the database structure. It includes following statements:


Very basic is the create table statement, used to create a database table:

CREATE TABLE [table_name] (
[column1] datatype,
[column2] datatype,


ALTER statement is used to add, delete or modify database table columns.

ALTER TABLE [table_name]
ADD [column_name] datatype;

ALTER TABLE [table_name]
DROP COLUMN [column_name];

ALTER TABLE [table_name]
MODIFY COLUMN [column_name] datatype;


DROP statement is used to remove complete table definition with all data.

DROP TABLE [table_name];

2) Data Manipulation Language:

It is used to manipulate data in database. It includes following statements:


Very basic SELECT statement is for selecting rows and columns from the database table.

SELECT [*/column_name1, column_name2, ....]
FROM [table_name]
WHERE [condition];


UPDATE statement is used to modify records stored in database table.

UPDATE [table_name]
SET [coumn_name1 = value1], [column_name2  =  value2], [.....]
WHERE [condition];


INSERT statement is used to add new record/row in database table.

INSERT INTO [table_name] ([column_name1, coulmn_name2, .....])
VALUES ([value1, value2, .....]);


DELETE statement is used to remove record/row from database table.

DELETE FROM [table_name]
WHERE [condition];

3) Data Control Language:

It is used to handle database privileges. Basic privileges that can be granted or revoked from user are SELECT, UPDATE, INSERT, DELETE etc. 

It includes following statements:


GRANT statement is used to give various privileges to user on an particular table.

GRANT [privileges] ON [table_name] TO [user];


REVOKE statement is used to cancel the granted privilege to user on a particular table.

REVOKE [privileges] ON [table_name] FROM [user]; 


Popular posts from this blog

Define the terms: domain, tuple, attribute and relation

With the help of block diagram explain the architecture of a DBMS.

What are the different types of database users?