Structured query language syntax

 

All SQL syntax:

Structured query language is very powerful and important feature of any database management system as it is always required where manipulation,updating,deleting,creating,droping,rollback etc. works are required .

SQL select syntax:

SELECT column1, column2,column3….columnN FROM table_name;
SQL create database syntax:
CREATE DATABASE database_name;

SQL drop database syntax:
DROP DATABASE database_name;

SQL use syntax:
USE DATABASE database_name;
SQL desc syntax:
DESC table_name;

SQL truncate table syntax:
TRUNCATE TABLE table_name;

SQL alter table syntax:
ALTER TABLE table_name {ADD|DROP|MODIFY} column_name {data_ype};

SQL rename table syntax:
ALTER TABLE table_name RENAME TO new_table_name;

SQL insert into syntax:

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

SQL distinct syntax:
SELECT DISTINCT column1, column2,column3….columnN FROM table_name;

SQL where syntax:
SELECT column1, column2,column3….columnN FROM table_name
WHERE CONDITION;

SQL like syntax:
SELECT column1, column2,column3….columnN FROM table_name
WHERE column_name LIKE { PATTERN };

SQL order by syntax:
SELECT column1, column2,column3….columnN FROM table_name
WHERE CONDITION ORDER BY column_name {ASC|DESC};

SQL group by synatax:
SELECT SUM(column_name) FROM table_name
WHERE CONDITION GROUP BY column_name;

SQL Count Syntax:
SELECT COUNT(column_name) FROM table_name
WHERE CONDITION;

SQL HAVING Syntax:
SELECT SUM(column_name) FROM table_name
WHERE CONDITION GROUP BY column_name HAVING (arithematic function condition);

SQL CREATE TABLE syntax:
CREATE TABLE table_name(column1 datatype, column2 datatype, column3 datatype,column4 datatype, ….. columnN datatype,
PRIMARY KEY( one or more columns ) );

SQL drop syntax:
DROP TABLE table_name;
SQL AND |OR SYNTAX:
SELECT column1, column2,column3….columnN FROM table_name
WHERE CONDITION-1 {AND|OR} CONDITION-2;

SQL IN Syntax:
SELECT column1, column2,column3….columnN FROM table_name WHERE column_name IN (val-1, val-2,…val-N);

SQL between syntax:
SELECT column1, column2,column3….columnN FROM table_name
WHERE column_name BETWEEN val-1 AND val-2;

SQL create index syntax:
CREATE UNIQUE INDEX index_name ON table_name ( column1, ccolumn2,column3,…columnN);

SQL drop index syntax:
ALTER TABLE table_name DROP INDEX index_name;

SQL update syntax:
UPDATE table_name
SET column1 = value1, column2 = value2….columnN=valueN [ WHERE CONDITION ];

SQL delete syntax:
DELETE FROM table_name WHERE {CONDITION};

SQL commit syntax:
COMMIT;

SQL rollback syntax:
ROLLBACK;

Read as pdf