How to select, insert, update, delete all statements


SQL Statements Select, Insert, Update, Delete, Alter All Statements

All the SQL statements start with any of the keywords like SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW and all the statements end with a semicolon (;).


SQL SELECT Statement

SELECT column1, column2....columnN FROM table_name;

SQL DISTINCT Clause

SELECT DISTINCT column1, column2....columnN FROM table_name;

SQL WHERE Clause

SELECT column1, column2....columnN FROM table_name WHERE CONDITION;

SQL AND/OR Clause

SELECT column1, column2....columnN FROM table_name WHERE CONDITION-1 {AND|OR} CONDITION-2;

SQL IN Clause

SELECT column1, column2....columnN FROM table_name WHERE column_name IN 
(val-1, val-2,...val-N);

SQL BETWEEN Clause

SELECT column1, column2....columnN FROM table_name WHERE column_name 
BETWEEN val-1 AND val-2;

SQL LIKE Clause

SELECT column1, column2....columnN FROM table_name WHERE column_name LIKE { PATTERN };


SQL ORDER BY Clause

SELECT column1, column2....columnN FROM table_name WHERE CONDITION ORDER BY column_name {ASC|DESC};

SQL GROUP BY Clause

SELECT SUM(column_name) FROM table_name WHERE CONDITION GROUP BY column_name;

SQL COUNT Clause

SELECT COUNT(column_name) FROM table_name WHERE CONDITION;

SQL CREATE TABLE Statement

CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype, ..... columnN datatype, PRIMARY KEY( one or more columns ) );


SQL DROP INDEX Statement

ALTER TABLE table_name DROP INDEX index_name;

SQL DESC Statement

DESC table_name;

SQL TRUNCATE TABLE Statement

TRUNCATE TABLE table_name;


  SQL DELETE Statement

DELETE FROM table_name WHERE {CONDITION};

SQL ALTER TABLE Statement

ALTER TABLE table_name {ADD|DROP|MODIFY} column_name {data_ype};

SQL ALTER TABLE Statement (Rename)

ALTER TABLE table_name RENAME TO new_table_name;


SQL INSERT INTO Statement

INSERT INTO table_name( column1, column2....columnN) VALUES ( value1, value2....valueN);


SQL COMMIT Statement

COMMIT;

SQL ROLLBACK Statement

ROLLBACK;

SQL CREATE DATABASE Statement

CREATE DATABASE database_name;



Post a Comment

0 Comments