\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{Hoejlund (Hoejlund)} \pdfinfo{ /Title (h2-database-1-sql.pdf) /Creator (Cheatography) /Author (Hoejlund (Hoejlund)) /Subject (H2 DATABASE 1 - SQL 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}{990000} \definecolor{LightBackground}{HTML}{FBF7F7} \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{H2 DATABASE 1 - SQL Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Hoejlund (Hoejlund)} via \textcolor{DarkBackground}{\uline{cheatography.com/45515/cs/13431/}}} \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}Hoejlund (Hoejlund) \\ \uline{cheatography.com/hoejlund} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 10th November, 2017.\\ Updated 10th November, 2017.\\ 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*}{2} \begin{tabularx}{8.4cm}{x{2 cm} x{6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Server Roles}} \tn % Row 0 \SetRowColor{LightBackground} sysadmin & Role members can perform all activities possible on the Database Engine instance. You specify initial membership of this role when performing installation of the Database Engine feature \tn % Row Count 7 (+ 7) % Row 1 \SetRowColor{white} \seqsplit{serveradmin} & Role members can perform instance-wide configuration tasks. Members of this role can shut down the instance \tn % Row Count 11 (+ 4) % Row 2 \SetRowColor{LightBackground} \seqsplit{securityadmin} & Assign this role to logins that must be able to manage instance-level permissions \tn % Row Count 14 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{processadmin} & Role members can terminate processes running on a Database Engine instance. \tn % Row Count 17 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{setupadmin} & Role members can add linked servers to and remove linked servers from the Database Engine instance. \tn % Row Count 21 (+ 4) % Row 5 \SetRowColor{white} bulkadmin & Assign this role to logins that you want to allow to use the BULK INSERT statement on databases hosted on an instance. \tn % Row Count 25 (+ 4) % Row 6 \SetRowColor{LightBackground} diskadmin & Role members can manage instance-related files \tn % Row Count 27 (+ 2) % Row 7 \SetRowColor{white} dbcreator & Role members are able to create, alter, drop, and restore databases hosted on the Database Engine instance \tn % Row Count 31 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{2 cm} x{6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Server Roles (cont)}} \tn % Row 8 \SetRowColor{LightBackground} public & All SQL Server logins are members of this role. \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.9 cm} x{2.28 cm} x{3.42 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Installation of SQL Server}} \tn % Row 0 \SetRowColor{LightBackground} Feature Selection & Database Engine Services & Includes the Database Engine, the core service for storing. \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \seqsplit{Installation} & New SQL Server stand-alone & Installing the final SQL Server in a non-clustered enviroment \tn % Row Count 8 (+ 4) % Row 2 \SetRowColor{LightBackground} Setup Support Rukes & Status of rules & should pass all the rules \tn % Row Count 10 (+ 2) % Row 3 \SetRowColor{white} Instance \seqsplit{Configuration} & Default Instance & Choose the default instance configuration \tn % Row Count 13 (+ 3) % Row 4 \SetRowColor{LightBackground} Engine \seqsplit{Configuration} & Specify Server Admins & add a new or current user \tn % Row Count 15 (+ 2) % Row 5 \SetRowColor{white} Engine \seqsplit{Configuration} & \seqsplit{Authentication} Mode & Choosing Mixed Mode - and setting up password \tn % Row Count 18 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.56 cm} x{5.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Monitoring Tools}} \tn % Row 0 \SetRowColor{LightBackground} SQL Server Profiler & tracks engine process events, such as the start of a batch or a transaction \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Distributed Replay & use multiple computers to replay trace data, simulating a mission-critical workload. \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} System Monitor & primarily tracks resource usage \tn % Row Count 9 (+ 2) % Row 3 \SetRowColor{white} Activity Monitor & displays information about: Processes running, Blocked processes, Locks, User activity. \tn % Row Count 13 (+ 4) % Row 4 \SetRowColor{LightBackground} \seqsplit{Transact-SQL} & Transact-SQL stored procedures that create, filter, and define tracing: \tn % Row Count 16 (+ 3) % Row 5 \SetRowColor{white} Error logs & The Windows application event log provides an overall picture of events occurring on the Windows Server \tn % Row Count 20 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2 cm} x{6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Date data types}} \tn % Row 0 \SetRowColor{LightBackground} datetime & From January 1, 1753 to December 31, 9999 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{smalldatetime} & From January 1, 1900 to June 6, 2079 \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} date & Store a date only. \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} time & Store a time only to an accuracy of 100 nanoseconds \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Setup of AD Sever}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{ADDS} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{DHCP} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{DNS} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{1.04 cm} x{6.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{System Databases}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Master} & Records all the system-level information for an instance of SQL Server. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Model & Is used as the template for all databases \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} MSDB & Is used by SQL Server Agent for scheduling alerts and jobs. \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{TEMPDB} & Is a workspace for holding temporary objects or intermediate result sets. \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.52 cm} x{3.42 cm} x{2.66 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{String data types}} \tn % Row 0 \SetRowColor{LightBackground} char(n) & Fixed width character string & 8,000 characters \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{varchar(n)} & Variable width character string & 8,000 characters \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{varchar(max)} & Variable width character string & 1,073,741,824 characters \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} text & Variable width character string & 2GB of text data \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} nchar & Fixed width Unicode string & 4,000 characters \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{nvarchar} & Variable width Unicode string & 4,000 characters \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} \seqsplit{nvarchar(max)} & Variable width Unicode string & 536,870,912 characters \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} ntext & Variable width Unicode string & 2GB of text data \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} \seqsplit{binary(n)} & Fixed width binary string & 8,000 bytes \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} \seqsplit{varbinary} & Variable width binary string & 8,000 bytes \tn % Row Count 20 (+ 2) % Row 10 \SetRowColor{LightBackground} \seqsplit{varbinary(max)} & Variable width binary string & 2GB \tn % Row Count 22 (+ 2) % Row 11 \SetRowColor{white} image & Variable width binary string & 2GB \tn % Row Count 24 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{List of relational databases}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Oracle} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{MySQL} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Microsoft SQL Server} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{PostgreSQL} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{IBM DB2} \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{A relational database management system, is a database management system that is based on the relational model. \newline \newline Relational databases have often replaced legacy hierarchical databases and network databases because they are easier to understand and use.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Designing the Installation}} \tn % Row 0 \SetRowColor{LightBackground} Database Engine Services & Provides the core service for storing, processing, and securing data \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} SQL Server Replication & Allows for copying and distributing data and database objects from one database to another \tn % Row Count 9 (+ 5) % Row 2 \SetRowColor{LightBackground} Full-Text and Semantic Extractions For Search & Supports Full-Text Extraction for fast text search \tn % Row Count 12 (+ 3) % Row 3 \SetRowColor{white} Data Quality Services & Facilitates both computer-assisted and interactive methods of managing data source quality and integrity \tn % Row Count 18 (+ 6) % Row 4 \SetRowColor{LightBackground} Analysis Services & Supports online analytical processing (OLAP) and data mining \tn % Row Count 21 (+ 3) % Row 5 \SetRowColor{white} Reporting Services – Native & Facilitates the creation, management, and delivery of reports through email and interactive web-based formats \tn % Row Count 27 (+ 6) % Row 6 \SetRowColor{LightBackground} Reporting Services – SharePoint & Integrates report viewing and management through SharePoint. \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Designing the Installation (cont)}} \tn % Row 7 \SetRowColor{LightBackground} Reporting Services Add-in & Provides management and user interfaces that allow integration between SharePoint and SQL Server Reporting Services (SSRS). \tn % Row Count 7 (+ 7) % Row 8 \SetRowColor{white} Data Quality Client & Interacts with data source quality and integrity services \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}