\documentclass[10pt,a4paper]{article}

% Packages
\usepackage{fancyhdr}           % For header and footer
\usepackage{multicol}           % Allows multicols in tables
\usepackage{tabularx}           % Intelligent column widths
\usepackage{tabulary}           % Used in header and footer
\usepackage{hhline}             % Border under tables
\usepackage{graphicx}           % For images
\usepackage{xcolor}             % For hex colours
%\usepackage[utf8x]{inputenc}    % For unicode character support
\usepackage[T1]{fontenc}        % Without this we get weird character replacements
\usepackage{colortbl}           % For coloured tables
\usepackage{setspace}           % For line height
\usepackage{lastpage}           % Needed for total page number
\usepackage{seqsplit}           % Splits long words.
%\usepackage{opensans}          % Can't make this work so far. Shame. Would be lovely.
\usepackage[normalem]{ulem}     % For underlining links
% Most of the following are not required for the majority
% of cheat sheets but are needed for some symbol support.
\usepackage{amsmath}            % Symbols
\usepackage{MnSymbol}           % Symbols
\usepackage{wasysym}            % Symbols
%\usepackage[english,german,french,spanish,italian]{babel}              % Languages

% Document Info
\author{Nima (nimakarimian)}
\pdfinfo{
  /Title (sql-cheatsheet.pdf)
  /Creator (Cheatography)
  /Author (Nima (nimakarimian))
  /Subject (SQL CheatSheet Cheat Sheet)
}

% Lengths and widths
\addtolength{\textwidth}{6cm}
\addtolength{\textheight}{-1cm}
\addtolength{\hoffset}{-3cm}
\addtolength{\voffset}{-2cm}
\setlength{\tabcolsep}{0.2cm} % Space between columns
\setlength{\headsep}{-12pt} % Reduce space between header and content
\setlength{\headheight}{85pt} % If less, LaTeX automatically increases it
\renewcommand{\footrulewidth}{0pt} % Remove footer line
\renewcommand{\headrulewidth}{0pt} % Remove header line
\renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit
% This two commands together give roughly
% the right line height in the tables
\renewcommand{\arraystretch}{1.3}
\onehalfspacing

% Commands
\newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour
\newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols
\newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns
\newcommand{\tn}{\tabularnewline} % Required as custom column type in use

% Font and Colours
\definecolor{HeadBackground}{HTML}{333333}
\definecolor{FootBackground}{HTML}{666666}
\definecolor{TextColor}{HTML}{333333}
\definecolor{DarkBackground}{HTML}{BE1DDE}
\definecolor{LightBackground}{HTML}{FAF0FC}
\renewcommand{\familydefault}{\sfdefault}
\color{TextColor}

% Header and Footer
\pagestyle{fancy}
\fancyhead{} % Set header to blank
\fancyfoot{} % Set footer to blank
\fancyhead[L]{
\noindent
\begin{multicols}{3}
\begin{tabulary}{5.8cm}{C}
    \SetRowColor{DarkBackground}
    \vspace{-7pt}
    {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent
        \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}}
    }
\end{tabulary}
\columnbreak
\begin{tabulary}{11cm}{L}
    \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{SQL CheatSheet Cheat Sheet}}}} \\
    \normalsize{by \textcolor{DarkBackground}{Nima (nimakarimian)} via \textcolor{DarkBackground}{\uline{cheatography.com/113429/cs/33110/}}}
\end{tabulary}
\end{multicols}}

\fancyfoot[L]{ \footnotesize
\noindent
\begin{multicols}{3}
\begin{tabulary}{5.8cm}{LL}
  \SetRowColor{FootBackground}
  \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}}  \\
  \vspace{-2pt}Nima (nimakarimian) \\
  \uline{cheatography.com/nimakarimian} \\
        \uline{\seqsplit{www}.nimakarimian.ir}
  \end{tabulary}
\vfill
\columnbreak
\begin{tabulary}{5.8cm}{L}
  \SetRowColor{FootBackground}
  \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}}  \\
   \vspace{-2pt}Published 18th July, 2022.\\
   Updated 18th July, 2022.\\
   Page {\thepage} of \pageref{LastPage}.
\end{tabulary}
\vfill
\columnbreak
\begin{tabulary}{5.8cm}{L}
  \SetRowColor{FootBackground}
  \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}}  \\
  \SetRowColor{white}
  \vspace{-5pt}
  %\includegraphics[width=48px,height=48px]{dave.jpeg}
  Measure your website readability!\\
  www.readability-score.com
\end{tabulary}
\end{multicols}}




\begin{document}
\raggedright
\raggedcolumns

% Set font size to small. Switch to any value
% from this page to resize cheat sheet text:
% www.emerson.emory.edu/services/latex/latex_169.html
\footnotesize % Small font.

\begin{multicols*}{3}

\begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{SELECT}}  \tn
% Row 0
\SetRowColor{LightBackground}
Specific Columns & `Select Col1,Col2,...,Col n from tablename` \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
Select Distinct & `Select Distinct * from tablename` \tn 
% Row Count 4 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{5.377cm}}{{\bf{you can show the results in your desired name by using 'AS' clause like :}} \newline select Count(*) as CountryCount from ( select Country from Customers)}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{GROUP BY}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{SELECT column\_name(s) \newline FROM table\_name \newline WHERE condition \newline GROUP BY column\_name(s) \newline ORDER BY column\_name(s);} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{{\bf{The GROUP BY statement groups rows that have the same values into summary rows, like "find the}} {\bf{number of customers in each country".}} \newline  \newline {\bf{The GROUP BY statement is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result-set by one or more columns.}}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{INSERT INTO}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{INSERT INTO table\_name (column1, column2, column3, ...) \newline VALUES (value1, value2, value3, ...);} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{0.9954 cm} x{3.9816 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{SELECT TOP}}  \tn
% Row 0
\SetRowColor{LightBackground}
SQL SERVER & `SELECT TOP number|percent column\_name(s) FROM table\_name WHERE condition;` \tn 
% Row Count 3 (+ 3)
% Row 1
\SetRowColor{white}
MYSQL & `SELECT column\_name(s) FROM table\_name WHERE condition LIMIT number;` \tn 
% Row Count 6 (+ 3)
% Row 2
\SetRowColor{LightBackground}
ORACLE & `SELECT column\_name(s) FROM table\_name ORDER BY column\_name(s) FETCH FIRST number ROWS ONLY;` \tn 
% Row Count 9 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{5.377cm}}{{\bf{Not all database systems support the `SELECT TOP` clause. MySQL supports the `LIMIT` clause to select a limited number of records, while Oracle uses `FETCH FIRST n ROWS ONLY` and `ROWNUM`.}}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{BETWEEN}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{SELECT column\_name(s) \newline FROM table\_name \newline WHERE column\_name BETWEEN value1 AND value2; \newline  \newline // {\emph{you can also use NOT with BETWEEN}} \newline  \newline SELECT * FROM Products \newline WHERE ProductName NOT BETWEEN value1 AND value2} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{LIKE}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{SELECT column1, column2, ... \newline FROM table\_name \newline WHERE columnN LIKE pattern; \newline  \newline  \newline WHERE CustomerName LIKE 'a\%=={\bf{Finds any values that start with "a"}}} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{{\bf{The percent sign (\%) represents zero, one, or multiple characters}} \newline {\bf{The underscore sign (\_) represents one, single character}} \newline  You can also combine any number of conditions using AND or OR operators.}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{1.24425 cm} x{3.73275 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{VIEW}}  \tn
% Row 0
\SetRowColor{LightBackground}
CREATE VIEW & `CREATE VIEW view\_name AS SELECT column1, column2, ... FROM table\_name WHERE condition;` \tn 
% Row Count 3 (+ 3)
% Row 1
\SetRowColor{white}
UPDATING VIEW & `CREATE OR REPLACE VIEW view\_name AS SELECT column1, column2, ... FROM table\_name WHERE condition;` \tn 
% Row Count 7 (+ 4)
% Row 2
\SetRowColor{LightBackground}
DROPPING VIEW & `DROP VIEW view\_name;` \tn 
% Row Count 9 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{CKECK}}  \tn
% Row 0
\SetRowColor{LightBackground}
MYSQL - CREATE TABLE - & `CREATE TABLE Persons (     ID int NOT NULL,     LastName varchar(255) NOT NULL,     FirstName varchar(255),     Age int,     CHECK (Age\textgreater{}=18) );` \tn 
% Row Count 8 (+ 8)
% Row 1
\SetRowColor{white}
Others -CREATE TABLE- & `CREATE TABLE Persons (     ID int NOT NULL,     LastName varchar(255) NOT NULL,     FirstName varchar(255),     Age int CHECK (Age\textgreater{}=18) );` \tn 
% Row Count 15 (+ 7)
% Row 2
\SetRowColor{LightBackground}
Multiple Columns and Naming & `CREATE TABLE Persons (     ID int NOT NULL,     LastName varchar(255) NOT NULL,     FirstName varchar(255),     Age int,     City varchar(255),     CONSTRAINT CHK\_Person CHECK (Age\textgreater{}=18 AND City='Sandnes') );` \tn 
% Row Count 26 (+ 11)
% Row 3
\SetRowColor{white}
CHECK -ALTERTABLE- & `ALTER TABLE Persons ADD CHECK (Age\textgreater{}=18);` \tn 
% Row Count 29 (+ 3)
% Row 4
\SetRowColor{LightBackground}
Multiple Columns and naming -ALTERTABLE- & `ALTER TABLE Persons ADD CONSTRAINT CHK\_PersonAge CHECK (Age\textgreater{}=18 AND City='Sandnes');` \tn 
% Row Count 34 (+ 5)
\end{tabularx}
\par\addvspace{1.3em}

\vfill
\columnbreak
\begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{CKECK (cont)}}  \tn
% Row 5
\SetRowColor{LightBackground}
DROP CHECK -MYSQL- & `ALTER TABLE Persons DROP CONSTRAINT CHK\_PersonAge;` \tn 
% Row Count 3 (+ 3)
% Row 6
\SetRowColor{white}
DROP CHECK -Others- & `ALTER TABLE Persons DROP CHECK CHK\_PersonAge;` \tn 
% Row Count 6 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{UNIQUE}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{-{}- SQL SERVER -{}- \newline CREATE TABLE Persons ( \newline     ID int NOT NULL UNIQUE, \newline     LastName varchar(255) NOT NULL, \newline     FirstName varchar(255), \newline     Age int \newline ); \newline  \newline -{}- MYSQL -{}- \newline CREATE TABLE Persons ( \newline     ID int NOT NULL, \newline     LastName varchar(255) NOT NULL, \newline     FirstName varchar(255), \newline     Age int, \newline     UNIQUE (ID) \newline ); \newline -{}- Define multiple Unique keys -{}-  \newline CREATE TABLE Persons ( \newline     ID int NOT NULL, \newline     LastName varchar(255) NOT NULL, \newline     FirstName varchar(255), \newline     Age int, \newline     CONSTRAINT UC\_Person UNIQUE (ID,LastName) \newline );} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{The UNIQUE constraint ensures that all values in a column are different. \newline  \newline Both the UNIQUE and PRIMARY KEY constraints provide a guarantee for uniqueness for a column or set of columns. \newline  \newline A PRIMARY KEY constraint automatically has a UNIQUE constraint. \newline  \newline However, you can have many UNIQUE constraints per table, but only one PRIMARY KEY constraint per table.}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Stored procedures (User defined functions)}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{CREATE PROCEDURE procedure\_name \newline AS \newline sql\_statement \newline GO; \newline  \newline -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- \newline EXEC procedure\_name; \newline -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- \newline EXAMPLE ====\textgreater{} \newline  \newline CREATE PROCEDURE SelectAllCustomers @City nvarchar(30), @PostalCode nvarchar(10) \newline AS \newline SELECT * FROM Customers WHERE City = @City AND PostalCode = @PostalCode \newline GO; \newline -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- \newline EXEC SelectAllCustomers @City = 'London', @PostalCode = 'WA1 1DP'; \newline  \newline  \newline END EXAMPLE \textless{}====} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{1.09494 cm} x{3.88206 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{ISNULL}}  \tn
% Row 0
\SetRowColor{LightBackground}
MYSQL & `SELECT ProductName, UnitPrice * (UnitsInStock + IFNULL(UnitsOnOrder, 0)) FROM Products;` \tn 
% Row Count 3 (+ 3)
% Row 1
\SetRowColor{white}
SQL SERVER & `SELECT ProductName, UnitPrice * (UnitsInStock + ISNULL(UnitsOnOrder, 0)) FROM Products;` \tn 
% Row Count 6 (+ 3)
% Row 2
\SetRowColor{LightBackground}
ORACLE & `SELECT ProductName, UnitPrice * (UnitsInStock + NVL(UnitsOnOrder, 0)) FROM Products;` \tn 
% Row Count 9 (+ 3)
% Row 3
\SetRowColor{white}
\seqsplit{Alternative} & `SELECT ProductName, UnitPrice * (UnitsInStock + COALESCE(UnitsOnOrder, 0)) FROM Products;` \tn 
% Row Count 12 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{5.377cm}}{{\bf{ COALESCE() Function Works with MYSQL SQLSERVER and ORACLE }}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{ANY \& ALL}}  \tn
% Row 0
\SetRowColor{LightBackground}
ANY & `SELECT column\_name(s) FROM table\_name WHERE column\_name operator ANY   (SELECT column\_name   FROM table\_name   WHERE condition);` \tn 
% Row Count 4 (+ 4)
% Row 1
\SetRowColor{white}
ALL & `SELECT column\_name(s) FROM table\_name WHERE column\_name operator ALL   (SELECT column\_name   FROM table\_name   WHERE condition);` \tn 
% Row Count 8 (+ 4)
% Row 2
\SetRowColor{LightBackground}
SOME & `SELECT * FROM Products WHERE Price \textgreater{} SOME (SELECT Price FROM Products WHERE Price \textgreater{} 20);` \tn 
% Row Count 11 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{5.377cm}}{{\bf{returns a boolean value as a result}} \newline {\bf{The operator must be a standard comparison operator (=, \textless{}\textgreater{}, !=, \textgreater{}, \textgreater{}=, \textless{}, or \textless{}=).}}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{WHERE keyword}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{SELECT Col1,Col2 FROM tablename WHERE {\emph{condition}}} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{{\bf{WHERE}} is for when you want to declare a specific condition for the query. in the other hand, you want to filter the records  \newline {\bf{TIP1}} WHERE can be used in UPDATE, SELECT, DELETE, ETC...}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{UNION}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{SELECT column\_name(s) FROM table1 \newline UNION \newline SELECT column\_name(s) FROM table2; \newline  \newline  \newline {\emph{The UNION operator selects only distinct values by default. }} \newline {\emph{To allow duplicate values, use UNION ALL:}} \newline  \newline SELECT column\_name(s) FROM table1 \newline UNION \newline SELECT column\_name(s) FROM table2;} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{{\bf{The UNION operator is used to combine the result-set of two or more SELECT statements.}} \newline  \newline {\bf{Every SELECT statement within UNION must have the same number of columns}} \newline {\bf{The columns must also have similar data types}} \newline {\bf{The columns in every SELECT statement must also be in the same order}}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{1.29402 cm} x{3.68298 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Aliases}}  \tn
% Row 0
\SetRowColor{LightBackground}
Column Aliases & `SELECT column\_name AS alias\_name FROM table\_name;` \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
Table Aliases & `SELECT column\_name(s) FROM table\_name AS alias\_name;` \tn 
% Row Count 4 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{p{0.4577 cm} x{1.92234 cm} x{2.19696 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{WILDCARDS}}  \tn
% Row 0
\SetRowColor{LightBackground}
\% & Represents zero or more characters & bl\% finds bl, black, blue, and blob \tn 
% Row Count 3 (+ 3)
% Row 1
\SetRowColor{white}
\_ & Represents a single character & h\_t finds hot, hat, and hit \tn 
% Row Count 5 (+ 2)
% Row 2
\SetRowColor{LightBackground}
{[}{]} & Represents any single character within the brackets & h{[}oa{]}t finds hot and hat, but not hit \tn 
% Row Count 9 (+ 4)
% Row 3
\SetRowColor{white}
\textasciicircum{} & Represents any character not in the brackets & h{[}\textasciicircum{}oa{]}t finds hit, but not hot and hat \tn 
% Row Count 12 (+ 3)
% Row 4
\SetRowColor{LightBackground}
- & Represents any single character within the specified range & c{[}a-b{]}t finds cat and cbt \tn 
% Row Count 16 (+ 4)
\hhline{>{\arrayrulecolor{DarkBackground}}---}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{p{0.54747 cm} x{4.42953 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{MIN() \& MAX()}}  \tn
% Row 0
\SetRowColor{LightBackground}
MIN() & `SELECT MIN(column\_name) FROM table\_name WHERE condition;` \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
MAX() & `SELECT MAX(column\_name) FROM table\_name WHERE condition;` \tn 
% Row Count 4 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{5.377cm}}{{\bf{you can use MIN() and MAX() anywhere in any Query you like  \newline the examples above are just to show implementation}}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{1.69218 cm} x{3.28482 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{DELETE}}  \tn
% Row 0
\SetRowColor{LightBackground}
DELETE EVERYTHING & `DELETE FROM table\_name;` \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
DELETE WITH CONDITION & `DELETE FROM table\_name WHERE condition;` \tn 
% Row Count 4 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{NOTNULL}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{CREATE TABLE Persons ( \newline     ID int NOT NULL, \newline     LastName varchar(255) NOT NULL, \newline     FirstName varchar(255) NOT NULL, \newline     Age int \newline ); \newline  \newline -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- \newline ALTER TABLE Persons \newline MODIFY Age int NOT NULL;} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{{\emph{To create a NOT NULL constraint on the "Age" column when the "Persons" table is already created, use the above Code}}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{DATE}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{{\bf{ {\emph{DATE}} - format YYYY-MM-DD}} \newline {\bf{ {\emph{DATETIME}} - format: YYYY-MM-DD HH:MI:SS}} \newline {\bf{ {\emph{TIMESTAMP}} - format: YYYY-MM-DD HH:MI:SS}}  \newline  \newline FOR MYSQL===\textgreater{} \newline {\bf{ {\emph{YEAR}} - format YYYY or YY}} \newline \textless{}=== \newline  \newline  \newline FOR SQLSERVER===\textgreater{} \newline {\bf{ {\emph{TIMESTAMP}} - format: a unique number}} \newline \textless{}===} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{SELECT INTO (copy)}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{SELECT column1, column2, column3, ... \newline INTO newtable {[}IN externaldb{]} \newline FROM oldtable \newline WHERE condition;} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{`SELECT * INTO CustomersBackup2017 IN 'Backup.mdb'` \newline `FROM Customers;`}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{1.74195 cm} x{3.23505 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{DEFAULT}}  \tn
% Row 0
\SetRowColor{LightBackground}
DEFAULT -CREATE TABLE- & `CREATE TABLE Orders (     ID int NOT NULL,     OrderNumber int NOT NULL,     OrderDate date DEFAULT GETDATE() );` \tn 
% Row Count 5 (+ 5)
% Row 1
\SetRowColor{white}
ALTERTABLE -MYSQL- & `ALTER TABLE Persons ALTER City SET DEFAULT 'Sandnes';` \tn 
% Row Count 8 (+ 3)
% Row 2
\SetRowColor{LightBackground}
ALTERTABLE -SQLSERVER- & `ALTER TABLE Persons ADD CONSTRAINT df\_City DEFAULT 'Sandnes' FOR City;` \tn 
% Row Count 11 (+ 3)
% Row 3
\SetRowColor{white}
\seqsplit{ALTERTABLE-Oracle-} & `ALTER TABLE Persons MODIFY City DEFAULT 'Sandnes';` \tn 
% Row Count 13 (+ 2)
% Row 4
\SetRowColor{LightBackground}
\seqsplit{DROPTABLE-MYSQL-} & `ALTER TABLE Persons ALTER City DROP DEFAULT;` \tn 
% Row Count 15 (+ 2)
% Row 5
\SetRowColor{white}
DROPTABLE -Others- & `ALTER TABLE Persons ALTER COLUMN City DROP DEFAULT;` \tn 
% Row Count 18 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{CASE}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{CASE \newline     WHEN condition1 THEN result1 \newline     WHEN condition2 THEN result2 \newline     WHEN conditionN THEN resultN \newline     ELSE result \newline END;} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{1.59264 cm} x{3.38436 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Database}}  \tn
% Row 0
\SetRowColor{LightBackground}
CREATE & `CREATE DATABASE testDB;` \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
SHOW & `SHOW DATABASES` \tn 
% Row Count 2 (+ 1)
% Row 2
\SetRowColor{LightBackground}
DROP & `DROP DATABASE databasename;` \tn 
% Row Count 4 (+ 2)
% Row 3
\SetRowColor{white}
BACKUP & `BACKUP DATABASE databasename TO DISK = 'filepath';` \tn 
% Row Count 6 (+ 2)
% Row 4
\SetRowColor{LightBackground}
\seqsplit{Differential} BACKUP & `BACKUP DATABASE databasename TO DISK = 'filepath' WITH DIFFERENTIAL;` \tn 
% Row Count 9 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{ALTER table}}  \tn
% Row 0
\SetRowColor{LightBackground}
ADD Column & `ALTER TABLE table\_name ADD column\_name datatype;` \tn 
% Row Count 3 (+ 3)
% Row 1
\SetRowColor{white}
DROP Column & `ALTER TABLE table\_name DROP COLUMN column\_name;` \tn 
% Row Count 6 (+ 3)
% Row 2
\SetRowColor{LightBackground}
ALTER/MODIFY COLUMN  {\emph{SQLSERVER}} & `ALTER TABLE table\_name ALTER COLUMN column\_name datatype;` \tn 
% Row Count 9 (+ 3)
% Row 3
\SetRowColor{white}
ALTER/MODIFY COLUMN  {\emph{MYSQL}} & `ALTER TABLE table\_name MODIFY COLUMN column\_name datatype;` \tn 
% Row Count 12 (+ 3)
% Row 4
\SetRowColor{LightBackground}
ALTER/MODIFY COLUMN  {\emph{ORACLE}} & `ALTER TABLE table\_name MODIFY column\_name datatype;` \tn 
% Row Count 15 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PRIMARY KEY}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{-{}-MYSQL-{}- \newline  \newline  \newline CREATE TABLE Persons ( \newline     ID int NOT NULL, \newline     LastName varchar(255) NOT NULL, \newline     FirstName varchar(255), \newline     Age int, \newline     PRIMARY KEY (ID) \newline ); \newline -{}-SQLSERVER ORACLE-{}- \newline  \newline  \newline CREATE TABLE Persons ( \newline     ID int NOT NULL PRIMARY KEY, \newline     LastName varchar(255) NOT NULL, \newline     FirstName varchar(255), \newline     Age int \newline ); \newline  \newline  \newline -{}-Defining multiple Columns as PK-{}-  \newline CREATE TABLE Persons ( \newline     ID int NOT NULL, \newline     LastName varchar(255) NOT NULL, \newline     FirstName varchar(255), \newline     Age int, \newline     CONSTRAINT PK\_Person PRIMARY KEY (ID,LastName) \newline ); \newline  \newline {\emph{In the example above there is only ONE PRIMARY KEY (PK\_Person).}} \newline {\emph{ However, the VALUE of the primary key is made up of }} \newline {\emph{TWO COLUMNS (ID + LastName).}}} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{p{0.74655 cm} x{4.23045 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{SUM() \& AVG() \& COUNT ()}}  \tn
% Row 0
\SetRowColor{LightBackground}
AVG() & `SELECT AVG(column\_name) FROM table\_name WHERE condition;` \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
SUM() & `SELECT SUM(column\_name) FROM table\_name WHERE condition;` \tn 
% Row Count 4 (+ 2)
% Row 2
\SetRowColor{LightBackground}
\seqsplit{COUNT()} & `SELECT COUNT(column\_name) FROM table\_name WHERE condition;` \tn 
% Row Count 6 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{IN}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{SELECT column\_name(s) \newline FROM table\_name \newline WHERE column\_name IN (value1, value2, ...); \newline  \newline OR \newline  \newline SELECT column\_name(s) \newline FROM table\_name \newline WHERE column\_name IN (SELECT STATEMENT);} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{{\bf{The IN operator allows you to specify multiple values in a WHERE clause.}} \newline  \newline {\bf{The IN operator is a shorthand for multiple OR conditions.}}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{1.69218 cm} x{3.28482 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{UPDATE}}  \tn
% Row 0
\SetRowColor{LightBackground}
UPDATE WITH CONDITION & `UPDATE table\_name SET column1 = value1, column2 = value2, ... WHERE condition;` \tn 
% Row Count 4 (+ 4)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{5.377cm}}{{\bf{Be careful when updating records. If you omit the WHERE clause, ALL records will be updated!}}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{0.9954 cm} x{3.9816 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{JOINS}}  \tn
% Row 0
\SetRowColor{LightBackground}
INNER JOIN & `FROM table1 INNER JOIN table2 ON table1.column\_name = table2.column\_name;` \tn 
% Row Count 3 (+ 3)
% Row 1
\SetRowColor{white}
LEFT JOIN & ` FROM table1 LEFT JOIN table2 ON table1.Column = table2.Column` \tn 
% Row Count 5 (+ 2)
% Row 2
\SetRowColor{LightBackground}
RIGHT JOIN & `FROM table1 RIGHT JOIN table2 ON table1.column\_name = table2.column\_name;` \tn 
% Row Count 8 (+ 3)
% Row 3
\SetRowColor{white}
FULL JOIN & `FROM table1 FULL OUTER JOIN table2 ON table1.column\_name = table2.column\_name WHERE condition;` \tn 
% Row Count 11 (+ 3)
% Row 4
\SetRowColor{LightBackground}
SELF JOIN & `SELECT column\_name(s) FROM table1 T1, table1 T2 WHERE condition;` \tn 
% Row Count 14 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{ORDER BY}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{SELECT column1, column2, ... \newline FROM table\_name \newline ORDER BY column1, column2, ... ASC|DESC;} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Constraints}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{CREATE TABLE table\_name ( \newline     column1 datatype constraint, \newline     column2 datatype constraint, \newline     column3 datatype constraint, \newline     .... \newline );} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{Constraints can be specified when the table is created with the CREATE TABLE statement, or after the table is created with the ALTER TABLE statement. \newline  \newline {\emph{NOT NULL }} \newline {\emph{UNIQUE }} \newline {\emph{PRIMARY KEY}} \newline {\emph{FOREIGN KEY}} \newline {\emph{CHECK}} \newline {\emph{DEFAULT}} \newline {\emph{CREATE INDEX}}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{2.09034 cm} x{2.88666 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{PRIMARY KEY on ALTER TABLE}}  \tn
% Row 0
\SetRowColor{LightBackground}
ALTERTABLE SIMPLE & `ALTER TABLE Persons ADD PRIMARY KEY (ID);` \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
ALTERTABLE multiple or naming & `ALTER TABLE Persons ADD CONSTRAINT PK\_Person PRIMARY KEY (ID,LastName);` \tn 
% Row Count 6 (+ 4)
% Row 2
\SetRowColor{LightBackground}
DROP PK -MYSQL- & `ALTER TABLE Persons DROP PRIMARY KEY;` \tn 
% Row Count 8 (+ 2)
% Row 3
\SetRowColor{white}
DROP PK -Others- & `ALTER TABLE Persons DROP CONSTRAINT PK\_Person;` \tn 
% Row Count 11 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{FOREIGN KEY}}  \tn
% Row 0
\SetRowColor{LightBackground}
MYSQL - CREATE TABLE - & `CREATE TABLE Orders (     OrderID int NOT NULL,     OrderNumber int NOT NULL,     PersonID int,     PRIMARY KEY (OrderID),     FOREIGN KEY (PersonID) REFERENCES Persons(PersonID) );` \tn 
% Row Count 10 (+ 10)
% Row 1
\SetRowColor{white}
Others - CREATE TABLE - & `CREATE TABLE Orders (     OrderID int NOT NULL PRIMARY KEY,     OrderNumber int NOT NULL,     PersonID int FOREIGN KEY REFERENCES Persons(PersonID) );` \tn 
% Row Count 18 (+ 8)
% Row 2
\SetRowColor{LightBackground}
Multiple Rows or FK with Name & `CREATE TABLE Orders (     OrderID int NOT NULL,     OrderNumber int NOT NULL,     PersonID int,     PRIMARY KEY (OrderID),     CONSTRAINT FK\_PersonOrder FOREIGN KEY (PersonID)     REFERENCES Persons(PersonID) );` \tn 
% Row Count 29 (+ 11)
% Row 3
\SetRowColor{white}
FOREIGN KEY- ALTER TABLE - & `ALTER TABLE Orders ADD FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);` \tn 
% Row Count 33 (+ 4)
\end{tabularx}
\par\addvspace{1.3em}

\vfill
\columnbreak
\begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{FOREIGN KEY (cont)}}  \tn
% Row 4
\SetRowColor{LightBackground}
Multiple Rows or FK with Name -ALTER TABLE- & `ALTER TABLE Orders ADD CONSTRAINT FK\_PersonOrder FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);` \tn 
% Row Count 6 (+ 6)
% Row 5
\SetRowColor{white}
DROP FK -MYSQL- & `ALTER TABLE Orders DROP FOREIGN KEY FK\_PersonOrder;` \tn 
% Row Count 9 (+ 3)
% Row 6
\SetRowColor{LightBackground}
DROP FK -Others- & `ALTER TABLE Orders DROP CONSTRAINT FK\_PersonOrder;` \tn 
% Row Count 12 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{1.89126 cm} x{3.08574 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{TABLE}}  \tn
% Row 0
\SetRowColor{LightBackground}
CREATE & `CREATE TABLE table\_name (     column1 datatype,     column2 datatype,     column3 datatype,    .... );` \tn 
% Row Count 5 (+ 5)
% Row 1
\SetRowColor{white}
DROP & `DROP TABLE table\_name;` \tn 
% Row Count 6 (+ 1)
% Row 2
\SetRowColor{LightBackground}
CREATE from another Table & `CREATE TABLE new\_table\_name AS     SELECT column1, column2,...     FROM existing\_table\_name     WHERE ....;` \tn 
% Row Count 11 (+ 5)
% Row 3
\SetRowColor{white}
TRUNCATE & `TRUNCATE TABLE table\_name;` \tn 
% Row Count 13 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{5.377cm}}{{\bf{The TRUNCATE TABLE statement is used to delete the data inside a table, but not the table itself.}}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{INSET INTO}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{INSERT INTO table2 \newline SELECT * FROM table1 \newline WHERE condition;} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{{\bf{The INSERT INTO SELECT statement copies data from one table and inserts it into another table.}} \newline  \newline {\bf{The INSERT INTO SELECT statement requires that the data types in source and target tables}} {\bf{match.}}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{INDEX}}  \tn
% Row 0
\SetRowColor{LightBackground}
CREATE & `CREATE INDEX index\_name ON table\_name (column1, column2, ...);` \tn 
% Row Count 3 (+ 3)
% Row 1
\SetRowColor{white}
CREATE UNIQUE & `CREATE UNIQUE INDEX index\_name ON table\_name (column1, column2, ...);` \tn 
% Row Count 6 (+ 3)
% Row 2
\SetRowColor{LightBackground}
DROP \seqsplit{-SQLSERVER-} & `DROP INDEX \seqsplit{table\_name.index\_name;`} \tn 
% Row Count 8 (+ 2)
% Row 3
\SetRowColor{white}
DROP -MYSQL- & `ALTER TABLE table\_name DROP INDEX index\_name;` \tn 
% Row Count 10 (+ 2)
% Row 4
\SetRowColor{LightBackground}
DROP -ORACLE- & `DROP INDEX index\_name;` \tn 
% Row Count 12 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{AUTO INCREMENT}}  \tn
% Row 0
\SetRowColor{LightBackground}
CREATE TABLE  -MYSQL- & `CREATE TABLE Persons (     Personid int NOT NULL AUTO\_INCREMENT,     LastName varchar(255) NOT NULL,     FirstName varchar(255),     Age int,     PRIMARY KEY (Personid) );` \tn 
% Row Count 8 (+ 8)
% Row 1
\SetRowColor{white}
ALTERTABLE -MYSQL- & `ALTER TABLE Persons AUTO\_INCREMENT=100;` \tn 
% Row Count 10 (+ 2)
% Row 2
\SetRowColor{LightBackground}
CREATE TABLE -SQLSERVER- & `CREATE TABLE Persons (     Personid int IDENTITY(1,1) PRIMARY KEY,     LastName varchar(255) NOT NULL,     FirstName varchar(255),     Age int );` \tn 
% Row Count 17 (+ 7)
% Row 3
\SetRowColor{white}
CREATE SEQUENCE -ORACLE- & `CREATE SEQUENCE seq\_person MINVALUE 1 START WITH 1 INCREMENT BY 1 CACHE 10;` \tn 
% Row Count 21 (+ 4)
% Row 4
\SetRowColor{LightBackground}
{\bf{ use sequence in oracle }} & `INSERT INTO Persons (Personid,FirstName,LastName) VALUES (seq\_person.nextval,'Lars','Monsen');` \tn 
% Row Count 26 (+ 5)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{EXISTS}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{SELECT column\_name(s) \newline FROM table\_name \newline WHERE EXISTS \newline (SELECT column\_name FROM table\_name WHERE condition);} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{{\bf{The EXISTS operator is used to test for the existence of any record in a subquery.}} \newline  \newline {\bf{The EXISTS operator returns TRUE if the subquery returns one or more records.}}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{HAVING}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{SELECT column\_name(s) \newline FROM table\_name \newline WHERE condition \newline GROUP BY column\_name(s) \newline HAVING condition \newline ORDER BY column\_name(s);} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{{\bf{The HAVING clause was added to SQL because the WHERE keyword cannot be used with aggregate functions.}}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}


% That's all folks
\end{multicols*}

\end{document}