SlideShare a Scribd company logo
SQL
Structured Query Language
Quick Reference Cards
http://www.techcanvass.com/
Copyrights @ Techcanvass | all rights reserved
SQL Command Types
Data Definition Language (DDL)
CREATE, ALTER, DROP, etc. DB objects / attributes
Data Manipulation Language (DML)
SELECT, INSERT, UPDATE, DELETE , etc data in DB
Data Control Language (DCL)
GRANT, REVOKE , etc for right & permissions
Transaction Control Language (TCL)
COMMIT, ROLLBACK, SAVEPOINT, etc for managing
transactions
Create a database
CREATE DATABASE database_name
Delete a database
DROP DATABASE database_name
Create a view in a database
CREATE VIEW view_name AS
SELECT column_name(s) FROM table_name
WHERE condition
Alter a view in a database
CREATE OR REPLACE VIEW view_name AS SELECT
columns FROM table WHERE conditions;
Delete a view in a database
DROP VIEW view_name;
Create a table in a database
CREATE TABLE "table_name"
("column_1" "data_type_for_column_1",
"column_2" "data_type_for_column_2“, ... )
Add columns in an existing table
ALTER TABLE table_name ADD column_name
datatype
Delete columns in an existing table
ALTER TABLE table_name DROP column_name
Delete a table
DROP TABLE table_name
Create a simple index
CREATE INDEX index_name
ON table_name (column_1, column_2, ...);
Create a unique index
CREATE UNIQUE INDEX index_name
ON table_name (column_1, column_2, ...);
Delete a index
DROP INDEX table_name.index_name;
Arithmetic Operators
+ (Addition), - (Subtraction), * (Multiplication),
/ (Division), % (Modulus)
Comparison Operators
= (Equal), <> (Not equal), > (Greater than),
< (Less than), >= (Greater than or equal),
<= (Less than or equal)
Logical Operators
IN ( ) - Matches a value in a list,
NOT - Negates a condition,
BETWEEN - Within a range (inclusive)
IS NULL - NULL value, IS NOT NULL - Non-NULL value
LIKE - Pattern matching with % and _
EXISTS - Condition is met if subquery returns at least
one row
Character Datatypes :CHAR(size) ,
VARCHARr2(size)…
Numeric Datatypes: NUMBER(size), NUMBER(P,S)
Date/Time Datatypes: DATE, TIMESTAMP…
Create / Alter / Delete Table
Create/Alter/Delete Views
Create / Delete Index
JOINS
Operators
Populate values for all the columns
INSERT INTO table_name VALUES (value1, value2,..);
Populate selective columns
INSERT INTO table_name (column1, column2,...)
VALUES (value1, value2,....);
Populate a table using another table
INSERT INTO table_name (column1, column2, ... )
SELECT col1, col2, ...colN
FROM second_table_name WHERE condition;
Update one or several columns in rows
UPDATE table_name
SET column_name_1 = new_value_1,
column_name_2 = new_value_2
WHERE column_name = some_value;
Updating table with data from another table
UPDATE table1
SET column1 = (SELECT expression1
FROM table2 WHERE conditions)
[WHERE conditions];
AVG Function
SELECT AVG(column or aggregate_expression)
FROM tables [WHERE conditions];
COUNT Function
SELECT COUNT(aggregate_expression)
FROM tables [WHERE conditions]
[ORDER BY expression [ ASC | DESC ]];
MAX Function
SELECT MAX(aggregate_expression)
FROM tables [WHERE conditions];
MIN Function
SELECT MIN(aggregate_expression)
FROM tables [WHERE conditions];
SUM Function
SELECT col1, col2, ... colN, SUM(aggregate_exp)
FROM tables [WHERE conditions]
GROUP BY exp1, exp2, ... expN;
Select all data from a table
SELECT * FROM table_name
Select only distinct data from a table
SELECT DISTINCT column_name(s)
FROM table_name
Select only certain data from a table
SELECT column_name(s) FROM table_name
WHERE column operator value
AND / OR column operator value;
Select data from a table with sort the rows
SELECT column_name(s) FROM table_name
ORDER BY row_1, row_2 DESC, row_3 ASC, ...;
IN Clause
SELECT column_name(s) FROM table_name
WHERE column_name IN (value1, value2, ...);
GROUP BY Clause
SELECT col1, col2, … ,aggregate_fn(aggregate_exp)
FROM tables [WHERE conditions]
GROUP BY col1,col2, …;
HAVING Clause
SELECT col1, col2, …, aggregate_fn(aggregate_exp)
FROM tables [WHERE conditions]
GROUP BY col1, col2, ...
HAVING aggregate_fn_condition;
UPDATE Statement
SELECT Statement
DELETE Statement
Aggregate Functions
Create / Delete Database (DB)
INSERT Statement
Alias ( Temporary Name)
LEFT Join
Select <columns> From A
Left Join B on A.Key = B.Key
Select <columns> From A
Left Join B where B.Key is null
A B
A B
RIGHT Join
Select <columns> From A
Right Join B on A.Key = B.Key
Select <columns> From A
Right Join B where B.Key is null
A B
BA
OUTER Join
Select <columns> From A
Full Outer Join B on A.Key =
B.Key
Select <columns> From A
Full Outer Join B where
A.Key is null AND B.Key is null
A B
A B
INNER (Simple) Join
Select <columns> From A
INNER Join B on A.Key = B.Key
A B
UNION removes duplicate rows
SELECT col1, col2, ... colN
FROM table1[WHERE conditions]
UNION
SELECT col1, col2, ... colN
FROM table2 [WHERE conditions];
UNION ALL does not remove duplicate row
SELECT col1, col2, ... colN
FROM table1[WHERE conditions]
UNION ALL
SELECT col1, col2, ... colN
FROM table2 [WHERE conditions];
SELECT col1, col2, ... colN
FROM A [WHERE conditions]
MINUS
SELECT col1, col2, ... colN
FROM B [WHERE conditions];
A B
Create Primary Key Constraint
CREATE TABLE table_name (
column1 datatype [ NULL | NOT NULL ],…
CONSTRAINT pk_name PRIMARY KEY (pk_col1,..) ;
Add Primary Key Constraint
ALTER TABLE A ADD CONSTRAINT constraint_name
PRIMARY KEY (col1,…);
Drop Primary Key
ALTER TABLE table_name DROP PRIMARY KEY;
Create Foreign Key Constraint
CREATE TABLE table_name (
column1 datatype [ NULL | NOT NULL ], ...
CONSTRAINT fk_column FOREIGN KEY (col1, …)
REFERENCES parent_table (col1, …));
Add Foreign Key Constraint
ALTER TABLE A ADD CONSTRAINT fk_name
FOREIGN KEY (col1, …)
REFERENCES parent_table (col1, …);
Drop Primary Key
ALTER TABLE A DROP CONSTRAINT constraint_name;
Create Unique Constraint
CREATE TABLE table_name (
column1 datatype [ NULL | NOT NULL ], ...
CONSTRAINT uq_name UNIQUE (uc_col1, ... ));
Drop Unique Constraint
ALTER TABLE A DROP CONSTRAINT constraint_name;
Create Check Constraint
CREATE TABLE table_name (
column1 datatype [ NULL | NOT NULL ], ...
CONSTRAINT ck_name CHECK (col1 condition));
UNION
Column name alias
SELECT column_name AS column_alias
FROM table_name;
Table name alias
SELECT table_alias.column_name
FROM table_name AS table_alias ;
Delete rows in a table
DELETE FROM table_name
WHERE column_name = some_value;
Deletes all data inside the table
TRUNCATE TABLE table_name;
Data Types
Primary Key Constraint
Foreign Key Constraint
Unique Key Constraint
Check Constraint
MINUS
+9122 4015 5175 +9122 2570 2772 +9120 6536 5845

More Related Content

What's hot

SQL Join Basic
SQL Join BasicSQL Join Basic
SQL Join Basic
Naimul Arif
 
Extensible Data Modeling
Extensible Data ModelingExtensible Data Modeling
Extensible Data Modeling
Karwin Software Solutions LLC
 
Oracle SQL AND PL/SQL
Oracle SQL AND PL/SQLOracle SQL AND PL/SQL
Oracle SQL AND PL/SQL
suriyae1
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer joinNargis Ehsan
 
SSIS Data Flow Tasks
SSIS Data Flow Tasks SSIS Data Flow Tasks
SSIS Data Flow Tasks
Ram Kedem
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Beat Signer
 
DML Commands
DML CommandsDML Commands
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
Hitesh Mohapatra
 
Mysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sqlMysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sql
Aimal Miakhel
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functions
Amrit Kaur
 
Sql views
Sql viewsSql views
Sql views
arshid045
 
Sql functions
Sql functionsSql functions
Sql functions
Ankit Dubey
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
kim.mens
 
SQL select clause
SQL select clauseSQL select clause
SQL select clause
arpit bhadoriya
 
data Normalization.pdf
data Normalization.pdfdata Normalization.pdf
data Normalization.pdf
BijayNag1
 
joins in database
 joins in database joins in database
joins in database
Sultan Arshad
 
The Art of Metaprogramming in Java
The Art of Metaprogramming in Java  The Art of Metaprogramming in Java
The Art of Metaprogramming in Java
Abdelmonaim Remani
 
Oracle Database View
Oracle Database ViewOracle Database View
Oracle Database View
Eryk Budi Pratama
 

What's hot (20)

SQL Join Basic
SQL Join BasicSQL Join Basic
SQL Join Basic
 
Extensible Data Modeling
Extensible Data ModelingExtensible Data Modeling
Extensible Data Modeling
 
ActiveRecord & ARel
ActiveRecord & ARelActiveRecord & ARel
ActiveRecord & ARel
 
Ref cursor
Ref cursorRef cursor
Ref cursor
 
Oracle SQL AND PL/SQL
Oracle SQL AND PL/SQLOracle SQL AND PL/SQL
Oracle SQL AND PL/SQL
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer join
 
SSIS Data Flow Tasks
SSIS Data Flow Tasks SSIS Data Flow Tasks
SSIS Data Flow Tasks
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 
DML Commands
DML CommandsDML Commands
DML Commands
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Mysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sqlMysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sql
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functions
 
Sql views
Sql viewsSql views
Sql views
 
Sql functions
Sql functionsSql functions
Sql functions
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
SQL select clause
SQL select clauseSQL select clause
SQL select clause
 
data Normalization.pdf
data Normalization.pdfdata Normalization.pdf
data Normalization.pdf
 
joins in database
 joins in database joins in database
joins in database
 
The Art of Metaprogramming in Java
The Art of Metaprogramming in Java  The Art of Metaprogramming in Java
The Art of Metaprogramming in Java
 
Oracle Database View
Oracle Database ViewOracle Database View
Oracle Database View
 

Similar to SQL Quick Reference Card

SQL : Structured Query Language
SQL : Structured Query LanguageSQL : Structured Query Language
SQL : Structured Query Language
Abhishek Gautam
 
1670595076250.pdf
1670595076250.pdf1670595076250.pdf
1670595076250.pdf
GaneshR321894
 
Cheat sheet SQL commands with examples and easy understanding
Cheat sheet SQL commands with examples and easy understandingCheat sheet SQL commands with examples and easy understanding
Cheat sheet SQL commands with examples and easy understanding
VivekanandaGN1
 
SQL 🌟🌟🔥.pdf
SQL 🌟🌟🔥.pdfSQL 🌟🌟🔥.pdf
SQL 🌟🌟🔥.pdf
LightWolf2
 
SQL learning notes and all code.pdf
SQL learning notes and all code.pdfSQL learning notes and all code.pdf
SQL learning notes and all code.pdf
79TarannumMulla
 
Basic sql(oracle) queries
Basic sql(oracle) queriesBasic sql(oracle) queries
Basic sql(oracle) queries
Harish Gyanani
 
Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01sagaroceanic11
 
SQL Class Note By Amit Maity PowerPoint Presentation
SQL Class Note By Amit Maity PowerPoint PresentationSQL Class Note By Amit Maity PowerPoint Presentation
SQL Class Note By Amit Maity PowerPoint Presentation
maitypradip938
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
jainendraKUMAR55
 
Oraclesql
OraclesqlOraclesql
Oraclesql
Priya Goyal
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 
Sql commands
Sql commandsSql commands
Sql commands
Mohd Tousif
 
Sql commands
Sql commandsSql commands
Sql commands
Mohd Tousif
 
MY SQL
MY SQLMY SQL
MY SQL
sundar
 

Similar to SQL Quick Reference Card (20)

dbms.pdf
dbms.pdfdbms.pdf
dbms.pdf
 
SQL : Structured Query Language
SQL : Structured Query LanguageSQL : Structured Query Language
SQL : Structured Query Language
 
1670595076250.pdf
1670595076250.pdf1670595076250.pdf
1670595076250.pdf
 
Cheat sheet SQL commands with examples and easy understanding
Cheat sheet SQL commands with examples and easy understandingCheat sheet SQL commands with examples and easy understanding
Cheat sheet SQL commands with examples and easy understanding
 
SQL 🌟🌟🔥.pdf
SQL 🌟🌟🔥.pdfSQL 🌟🌟🔥.pdf
SQL 🌟🌟🔥.pdf
 
SQL learning notes and all code.pdf
SQL learning notes and all code.pdfSQL learning notes and all code.pdf
SQL learning notes and all code.pdf
 
Basic sql(oracle) queries
Basic sql(oracle) queriesBasic sql(oracle) queries
Basic sql(oracle) queries
 
Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01
 
SQL Class Note By Amit Maity PowerPoint Presentation
SQL Class Note By Amit Maity PowerPoint PresentationSQL Class Note By Amit Maity PowerPoint Presentation
SQL Class Note By Amit Maity PowerPoint Presentation
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
Sql Tags
Sql TagsSql Tags
Sql Tags
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
Sql commands
Sql commandsSql commands
Sql commands
 
Sql commands
Sql commandsSql commands
Sql commands
 
Sql reference from w3 schools
Sql reference from w3 schools Sql reference from w3 schools
Sql reference from w3 schools
 
Les10
Les10Les10
Les10
 
MY SQL
MY SQLMY SQL
MY SQL
 
Les02
Les02Les02
Les02
 
Babitha2.mysql
Babitha2.mysqlBabitha2.mysql
Babitha2.mysql
 

More from Techcanvass

ECBA Exam Questions PDF | ECBA Sample Questions PDF | Techcanvass
ECBA Exam Questions PDF | ECBA Sample Questions PDF | TechcanvassECBA Exam Questions PDF | ECBA Sample Questions PDF | Techcanvass
ECBA Exam Questions PDF | ECBA Sample Questions PDF | Techcanvass
Techcanvass
 
Free CCBA exam questions PDF
Free CCBA exam questions PDFFree CCBA exam questions PDF
Free CCBA exam questions PDF
Techcanvass
 
Selenium web element commands cheat sheet
Selenium web element commands   cheat sheetSelenium web element commands   cheat sheet
Selenium web element commands cheat sheet
Techcanvass
 
CBAP Certification Overview
CBAP Certification OverviewCBAP Certification Overview
CBAP Certification Overview
Techcanvass
 
CCBA Certification Overview
CCBA Certification OverviewCCBA Certification Overview
CCBA Certification Overview
Techcanvass
 
5 things to do to become a Business Analyst
5 things to do to become a Business Analyst5 things to do to become a Business Analyst
5 things to do to become a Business Analyst
Techcanvass
 
Business analysis Fundamentals | Fundamentals of business analysis
Business analysis Fundamentals | Fundamentals of business analysisBusiness analysis Fundamentals | Fundamentals of business analysis
Business analysis Fundamentals | Fundamentals of business analysis
Techcanvass
 
What is Data Dictionary - BABOK technique
What is Data Dictionary - BABOK techniqueWhat is Data Dictionary - BABOK technique
What is Data Dictionary - BABOK technique
Techcanvass
 
Selenium Interview Questions & Answers
Selenium Interview Questions & AnswersSelenium Interview Questions & Answers
Selenium Interview Questions & Answers
Techcanvass
 
IIBA ECBA Certification Exam preparation Strategy
IIBA ECBA Certification Exam preparation StrategyIIBA ECBA Certification Exam preparation Strategy
IIBA ECBA Certification Exam preparation Strategy
Techcanvass
 
User stories basics
User stories basicsUser stories basics
User stories basics
Techcanvass
 
Business analyst certifications
Business analyst certificationsBusiness analyst certifications
Business analyst certifications
Techcanvass
 
CBAP sample questions
CBAP sample questionsCBAP sample questions
CBAP sample questions
Techcanvass
 
Selenium Tutorial for Beginners | Automation framework Basics
Selenium Tutorial for Beginners | Automation framework BasicsSelenium Tutorial for Beginners | Automation framework Basics
Selenium Tutorial for Beginners | Automation framework Basics
Techcanvass
 
Agile business analyst
Agile business analystAgile business analyst
Agile business analyst
Techcanvass
 
Agile Scrum Quick Reference Card
Agile Scrum Quick Reference CardAgile Scrum Quick Reference Card
Agile Scrum Quick Reference Card
Techcanvass
 
CBAP Certification Basics
CBAP Certification BasicsCBAP Certification Basics
CBAP Certification Basics
Techcanvass
 
IIBA BABOK version 3 - What's inside
IIBA BABOK version 3 - What's insideIIBA BABOK version 3 - What's inside
IIBA BABOK version 3 - What's inside
Techcanvass
 
Business Analysis Core Concepts Model (BACCM)
Business Analysis Core Concepts Model (BACCM)Business Analysis Core Concepts Model (BACCM)
Business Analysis Core Concepts Model (BACCM)
Techcanvass
 
Function point analysis introduction
Function point analysis introductionFunction point analysis introduction
Function point analysis introduction
Techcanvass
 

More from Techcanvass (20)

ECBA Exam Questions PDF | ECBA Sample Questions PDF | Techcanvass
ECBA Exam Questions PDF | ECBA Sample Questions PDF | TechcanvassECBA Exam Questions PDF | ECBA Sample Questions PDF | Techcanvass
ECBA Exam Questions PDF | ECBA Sample Questions PDF | Techcanvass
 
Free CCBA exam questions PDF
Free CCBA exam questions PDFFree CCBA exam questions PDF
Free CCBA exam questions PDF
 
Selenium web element commands cheat sheet
Selenium web element commands   cheat sheetSelenium web element commands   cheat sheet
Selenium web element commands cheat sheet
 
CBAP Certification Overview
CBAP Certification OverviewCBAP Certification Overview
CBAP Certification Overview
 
CCBA Certification Overview
CCBA Certification OverviewCCBA Certification Overview
CCBA Certification Overview
 
5 things to do to become a Business Analyst
5 things to do to become a Business Analyst5 things to do to become a Business Analyst
5 things to do to become a Business Analyst
 
Business analysis Fundamentals | Fundamentals of business analysis
Business analysis Fundamentals | Fundamentals of business analysisBusiness analysis Fundamentals | Fundamentals of business analysis
Business analysis Fundamentals | Fundamentals of business analysis
 
What is Data Dictionary - BABOK technique
What is Data Dictionary - BABOK techniqueWhat is Data Dictionary - BABOK technique
What is Data Dictionary - BABOK technique
 
Selenium Interview Questions & Answers
Selenium Interview Questions & AnswersSelenium Interview Questions & Answers
Selenium Interview Questions & Answers
 
IIBA ECBA Certification Exam preparation Strategy
IIBA ECBA Certification Exam preparation StrategyIIBA ECBA Certification Exam preparation Strategy
IIBA ECBA Certification Exam preparation Strategy
 
User stories basics
User stories basicsUser stories basics
User stories basics
 
Business analyst certifications
Business analyst certificationsBusiness analyst certifications
Business analyst certifications
 
CBAP sample questions
CBAP sample questionsCBAP sample questions
CBAP sample questions
 
Selenium Tutorial for Beginners | Automation framework Basics
Selenium Tutorial for Beginners | Automation framework BasicsSelenium Tutorial for Beginners | Automation framework Basics
Selenium Tutorial for Beginners | Automation framework Basics
 
Agile business analyst
Agile business analystAgile business analyst
Agile business analyst
 
Agile Scrum Quick Reference Card
Agile Scrum Quick Reference CardAgile Scrum Quick Reference Card
Agile Scrum Quick Reference Card
 
CBAP Certification Basics
CBAP Certification BasicsCBAP Certification Basics
CBAP Certification Basics
 
IIBA BABOK version 3 - What's inside
IIBA BABOK version 3 - What's insideIIBA BABOK version 3 - What's inside
IIBA BABOK version 3 - What's inside
 
Business Analysis Core Concepts Model (BACCM)
Business Analysis Core Concepts Model (BACCM)Business Analysis Core Concepts Model (BACCM)
Business Analysis Core Concepts Model (BACCM)
 
Function point analysis introduction
Function point analysis introductionFunction point analysis introduction
Function point analysis introduction
 

Recently uploaded

Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 

Recently uploaded (20)

Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 

SQL Quick Reference Card

  • 1. SQL Structured Query Language Quick Reference Cards http://www.techcanvass.com/ Copyrights @ Techcanvass | all rights reserved SQL Command Types Data Definition Language (DDL) CREATE, ALTER, DROP, etc. DB objects / attributes Data Manipulation Language (DML) SELECT, INSERT, UPDATE, DELETE , etc data in DB Data Control Language (DCL) GRANT, REVOKE , etc for right & permissions Transaction Control Language (TCL) COMMIT, ROLLBACK, SAVEPOINT, etc for managing transactions Create a database CREATE DATABASE database_name Delete a database DROP DATABASE database_name Create a view in a database CREATE VIEW view_name AS SELECT column_name(s) FROM table_name WHERE condition Alter a view in a database CREATE OR REPLACE VIEW view_name AS SELECT columns FROM table WHERE conditions; Delete a view in a database DROP VIEW view_name; Create a table in a database CREATE TABLE "table_name" ("column_1" "data_type_for_column_1", "column_2" "data_type_for_column_2“, ... ) Add columns in an existing table ALTER TABLE table_name ADD column_name datatype Delete columns in an existing table ALTER TABLE table_name DROP column_name Delete a table DROP TABLE table_name Create a simple index CREATE INDEX index_name ON table_name (column_1, column_2, ...); Create a unique index CREATE UNIQUE INDEX index_name ON table_name (column_1, column_2, ...); Delete a index DROP INDEX table_name.index_name; Arithmetic Operators + (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulus) Comparison Operators = (Equal), <> (Not equal), > (Greater than), < (Less than), >= (Greater than or equal), <= (Less than or equal) Logical Operators IN ( ) - Matches a value in a list, NOT - Negates a condition, BETWEEN - Within a range (inclusive) IS NULL - NULL value, IS NOT NULL - Non-NULL value LIKE - Pattern matching with % and _ EXISTS - Condition is met if subquery returns at least one row Character Datatypes :CHAR(size) , VARCHARr2(size)… Numeric Datatypes: NUMBER(size), NUMBER(P,S) Date/Time Datatypes: DATE, TIMESTAMP… Create / Alter / Delete Table Create/Alter/Delete Views Create / Delete Index JOINS Operators Populate values for all the columns INSERT INTO table_name VALUES (value1, value2,..); Populate selective columns INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....); Populate a table using another table INSERT INTO table_name (column1, column2, ... ) SELECT col1, col2, ...colN FROM second_table_name WHERE condition; Update one or several columns in rows UPDATE table_name SET column_name_1 = new_value_1, column_name_2 = new_value_2 WHERE column_name = some_value; Updating table with data from another table UPDATE table1 SET column1 = (SELECT expression1 FROM table2 WHERE conditions) [WHERE conditions]; AVG Function SELECT AVG(column or aggregate_expression) FROM tables [WHERE conditions]; COUNT Function SELECT COUNT(aggregate_expression) FROM tables [WHERE conditions] [ORDER BY expression [ ASC | DESC ]]; MAX Function SELECT MAX(aggregate_expression) FROM tables [WHERE conditions]; MIN Function SELECT MIN(aggregate_expression) FROM tables [WHERE conditions]; SUM Function SELECT col1, col2, ... colN, SUM(aggregate_exp) FROM tables [WHERE conditions] GROUP BY exp1, exp2, ... expN; Select all data from a table SELECT * FROM table_name Select only distinct data from a table SELECT DISTINCT column_name(s) FROM table_name Select only certain data from a table SELECT column_name(s) FROM table_name WHERE column operator value AND / OR column operator value; Select data from a table with sort the rows SELECT column_name(s) FROM table_name ORDER BY row_1, row_2 DESC, row_3 ASC, ...; IN Clause SELECT column_name(s) FROM table_name WHERE column_name IN (value1, value2, ...); GROUP BY Clause SELECT col1, col2, … ,aggregate_fn(aggregate_exp) FROM tables [WHERE conditions] GROUP BY col1,col2, …; HAVING Clause SELECT col1, col2, …, aggregate_fn(aggregate_exp) FROM tables [WHERE conditions] GROUP BY col1, col2, ... HAVING aggregate_fn_condition; UPDATE Statement SELECT Statement DELETE Statement Aggregate Functions Create / Delete Database (DB) INSERT Statement Alias ( Temporary Name) LEFT Join Select <columns> From A Left Join B on A.Key = B.Key Select <columns> From A Left Join B where B.Key is null A B A B RIGHT Join Select <columns> From A Right Join B on A.Key = B.Key Select <columns> From A Right Join B where B.Key is null A B BA OUTER Join Select <columns> From A Full Outer Join B on A.Key = B.Key Select <columns> From A Full Outer Join B where A.Key is null AND B.Key is null A B A B INNER (Simple) Join Select <columns> From A INNER Join B on A.Key = B.Key A B UNION removes duplicate rows SELECT col1, col2, ... colN FROM table1[WHERE conditions] UNION SELECT col1, col2, ... colN FROM table2 [WHERE conditions]; UNION ALL does not remove duplicate row SELECT col1, col2, ... colN FROM table1[WHERE conditions] UNION ALL SELECT col1, col2, ... colN FROM table2 [WHERE conditions]; SELECT col1, col2, ... colN FROM A [WHERE conditions] MINUS SELECT col1, col2, ... colN FROM B [WHERE conditions]; A B Create Primary Key Constraint CREATE TABLE table_name ( column1 datatype [ NULL | NOT NULL ],… CONSTRAINT pk_name PRIMARY KEY (pk_col1,..) ; Add Primary Key Constraint ALTER TABLE A ADD CONSTRAINT constraint_name PRIMARY KEY (col1,…); Drop Primary Key ALTER TABLE table_name DROP PRIMARY KEY; Create Foreign Key Constraint CREATE TABLE table_name ( column1 datatype [ NULL | NOT NULL ], ... CONSTRAINT fk_column FOREIGN KEY (col1, …) REFERENCES parent_table (col1, …)); Add Foreign Key Constraint ALTER TABLE A ADD CONSTRAINT fk_name FOREIGN KEY (col1, …) REFERENCES parent_table (col1, …); Drop Primary Key ALTER TABLE A DROP CONSTRAINT constraint_name; Create Unique Constraint CREATE TABLE table_name ( column1 datatype [ NULL | NOT NULL ], ... CONSTRAINT uq_name UNIQUE (uc_col1, ... )); Drop Unique Constraint ALTER TABLE A DROP CONSTRAINT constraint_name; Create Check Constraint CREATE TABLE table_name ( column1 datatype [ NULL | NOT NULL ], ... CONSTRAINT ck_name CHECK (col1 condition)); UNION Column name alias SELECT column_name AS column_alias FROM table_name; Table name alias SELECT table_alias.column_name FROM table_name AS table_alias ; Delete rows in a table DELETE FROM table_name WHERE column_name = some_value; Deletes all data inside the table TRUNCATE TABLE table_name; Data Types Primary Key Constraint Foreign Key Constraint Unique Key Constraint Check Constraint MINUS +9122 4015 5175 +9122 2570 2772 +9120 6536 5845