SQL follows a unique set of rules called Syntax and all operation done in Sql using queries (Insert, Update, Delete, Create etc) ,Statements, Clause .The main point to be noted is that Sql is Case insensitive, means create or Create have the same meaning, statement not depends on its case.
Select Statement
SELECT column1, column2....columnN FROM table_name;
Create Table
CREATE TABLE table_name(
CREATE TABLE table_name(
column1 datatype, column2 datatype, column3 datatype,..... columnN datatype,
PRIMARY KEY( one or more columns )
);
Insert Table
INSERT INTO table_name( column1, column2....columnN) VALUES ( value1,value2....N);
Update Table
UPDATE table_name
SET column1 = value1, column2 = value2....columnN=valueN
[ WHERE CONDITION ];
Delete Table
DELETE FROM table_name WHERE {CONDITION};
Drop Table
DROP TABLE table_name;
Create Datbase
CREATE DATABASE database_name;
Drop Database
DROP DATABASE database_name;
USE Statement:
USE database_name;
Truncate
TRUNCATE TABLE table_name;
COMMIT Statement:
COMMIT;
ROLLBACK Statement:
ROLLBACK;
Create Index
CREATE UNIQUE INDEX index_name ON table_name ( column1, column2,...columnN);
Drop Index
DROP INDEX index_name;
Desc Statement
DESC table_name;
ALTER TABLE Statement:
ALTER TABLE table_name {ADD|DROP|MODIFY} column_name {data_ype};
ALTER TABLE Statement (Rename) :
ALTER TABLE table_name RENAME TO new_table_name;
INSERT INTO Statement:
INSERT INTO table_name( column1, column2....columnN)
VALUES ( value1, value2....valueN);
DISTINCT Clause:
SELECT DISTINCT column1, column2....columnN FROM table_name;
WHERE Clause:
SELECT column1, column2....columnN FROM table_name WHERE CONDITION;
AND/OR Clause:
SELECT column1, column2....columnN FROM table_name WHERE CONDITION-1 {AND|OR} CONDITION-2;
IN Clause:
SELECT column1, column2....columnN FROM table_name WHERE column_name IN (val-1, val-2,...val-N);
BETWEEN Clause:
SELECT column1, column2....columnN FROM table_name WHERE column_name BETWEEN val-1 AND val-2;
LIKE Clause:
SELECT column1, column2....columnN FROM table_name WHERE column_name LIKE { PATTERN };
ORDER BY Clause:
SELECT column1, column2....columnN FROM table_name WHERE CONDITION ORDER BY column_name {ASC|DESC};
GROUP BY Clause:
SELECT SUM(column_name) FROM table_name WHERE CONDITION GROUP BY column_name;
COUNT Clause:
SELECT COUNT(column_name) FROM table_name WHERE CONDITION;
HAVING Clause:
SELECT SUM(column_name) FROM table_name WHERE CONDITION GROUP BY column_name HAVING (arithematic function condition);
SQL Aliase for Column:
SELECT column_name AS alias_name FROM table_name;
SQL Aliase for Table:
SELECT column_name(s)FROM table_name AS alias_name;
0 comments:
Post a Comment