\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{stofferdk} \pdfinfo{ /Title (sql-server-2016.pdf) /Creator (Cheatography) /Author (stofferdk) /Subject (SQL SERVER 2016 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}{341DA3} \definecolor{LightBackground}{HTML}{F2F0F9} \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 SERVER 2016 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{stofferdk} via \textcolor{DarkBackground}{\uline{cheatography.com/63592/cs/16933/}}} \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}stofferdk \\ \uline{cheatography.com/stofferdk} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 25th October, 2018.\\ 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{3.04 cm} x{4.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{SQL REQUIREMENTS}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{RAM}} & Min: 512 MB \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{HDD}} & Min: 6 GB \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{Windows PowerShell }} & Ver. 2.0 \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} {\bf{CPU}} & Min: x64 Processor 2.0 GHz or faster \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{Software}} & .Net 3.5 and 4 \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.28 cm} x{4.72 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{SQL2016 Sikkerhedsgrupper}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{db\_owner}} & Medlemmer kan udføre alt konfiguration \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{db\_securityadmin }} & Medlemmer kan modificere rettigheder \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{db\_accesadmin}} & Medlemmer kan tilføje/fjerne adgang til databasen \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} {\bf{db\_backupoperator}} & Medlemmer kan lave backup af databasen \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{db\_ddladmin}} & Medlemmer kan køre DDL i databasen \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} {\bf{db\_datawriter}} & Medlemmer kan ændre i tabellerne \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{db\_datareader }} & Medlemmer kan læse i tabellerne \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} {\bf{db\_denydatawriter }} & Medlemmer kan IKKE ændre i tabellerne \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} {\bf{db\_denydatareader }} & Medlemmer kan IKKE læse i tabellerne \tn % Row Count 19 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.84 cm} x{4.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Database Info}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Database}} & Består af en samling af informationer (data), der er systematiseret \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} {\bf{Relation Database}} & Er en database der er opbygget med en bestemt struktur. Dette vil sige at databasen indeholder forskellige elementer \seqsplit{(tabeller/entiteter)} \tn % Row Count 11 (+ 7) % Row 2 \SetRowColor{LightBackground} {\bf{Tabeller}} & En tabel er en samling af information vedrørende et bestemt emne \tn % Row Count 15 (+ 4) % Row 3 \SetRowColor{white} {\bf{Stored Procedure}} & Stored procedure er en underrutine til rådighed for tilsluttede relationelle database system applikationer \tn % Row Count 21 (+ 6) % Row 4 \SetRowColor{LightBackground} {\bf{View}} & I en database er et view resultatet af en lagret forespørgsel på dataene \tn % Row Count 25 (+ 4) % Row 5 \SetRowColor{white} {\bf{DBMS - Database Management System}} & Er et software, som bruges til at lave, læse, slette og opdatere en database \tn % Row Count 29 (+ 4) % Row 6 \SetRowColor{LightBackground} {\bf{SQL - Structured Query Language}} & SQL er et sprog der giver mulighed for at få adgang og manipulere data \tn % Row Count 33 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} p{0.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{4 Types Of DBMS}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\bf{Hierarchical }}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{{\bf{Network DBMS}}} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\bf{Relational DBMS }}} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{{\bf{Object Oriented Relation DBMS}}} \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.16 cm} x{5.84 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Firewall Regler}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Port 1433}} & SQL Server standard instans over TCP \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{Port 1434}} & Dedikeret Admin forbindelse \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{Port 4022}} & Service Broker \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.68 cm} x{6.32 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{DDL - Data Definition Language}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{CREATE}} & Oprette databaser, tabeller, view osv. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{ALTER}} & Ændre database objekter \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{DROP}} & Sletter database objekter \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.6 cm} x{6.4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{DQL - Data Query Language}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{SELECT}} & Henter tabeller af data \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{INSERT}} & Sætter nye tabeller af data i databasen \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{UPDATE}} & Bytter eksisterende værdier ud med nye værdier \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} {\bf{DELETE}} & Sletter tabeller \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.4 cm} x{5.6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{DML - Data Manipulation Language}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{SELECT }} & Læse data fra en tabel \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{INSERT}} & Indsæt ny data i en tabel \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{UPDATE}} & opdatere eksisterende data \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.6 cm} x{6.4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{DCL - Data Control Language}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{GRANT}} & Give rettigheder til en tabel for specifikke brugere \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{DENY}} & Udelukker specifikke rettigheder for brugere \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{REVOKE}} & Trække rettigheder tilbage fra brugere \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.48 cm} x{5.52 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{DATABASE Normalisering}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{1. Normalform }} & Der skal være en nøgle, der entydigt identificerer den enkelte række i tabellen • De enkelte felter må kun indeholde én værdi • Der må ikke være kolonner, der gentages. Løsningen kunne være at dele data op i to tabeller. En lånertabel og en udlånstabel. \tn % Row Count 10 (+ 10) % Row 1 \SetRowColor{white} {\bf{2. Normalform}} & Den opfylder alle krav til første normalform • Ingen attributter/egenskaber, der ikke selv tilhører nøglen må være en del af nøglen (sagt på en anden måde: Alle kolonner i en tabel skal indeholde data om én og kun én entitet). Løsningen kunne være at have tre tabeller: En bogtabel, en lånertabel og en udlånstabel, hvis eneste funktion er at håndtere selve udlånet \tn % Row Count 25 (+ 15) % Row 2 \SetRowColor{LightBackground} {\bf{3.Normalform}} & Løsningen kunne være at lave en separat tabel til at håndtere relationen mellem postnumre og by \tn % Row Count 29 (+ 4) % Row 3 \SetRowColor{white} {\bf{Opsamling}} & Normalisering handler om (så vidt muligt) at fjerne alle former for redundans med det formål at gøre databasen effektiv, konsistent og let at vedligeholde. \tn % Row Count 35 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.44 cm} x{4.56 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Select Queries}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Select all columns}} & SELECT * FROM table; \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{Select some columns}} & SELECT col1, col2 FROM table; \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{Select only unique records}} & SELECT DISTINCT FROM tbl WHERE condition; \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} {\bf{Column alias with AS}} & SELECT col FROM table AS newname; \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{Order results}} & SELECT * FROM table ORDER BY col {[}ASC | DESC{]}; \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} {\bf{Group results}} & SELECT col1, SUM(col2) FROM table GROUP BY col1; \tn % Row Count 14 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.04 cm} x{4.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Backup, Export og Import og Replikation}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Full Database Backup}} & En komplet Backup af Database \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{Trancaction Log}} & Kan genskabe en database tilbage til et bestemt punkt \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} {\bf{Eksport, Import}} & For at eksporter en database • Rettigheder til at læse Databasen • Rettigheder til destination af filen/databasen • Rettigheder til at oprette database, hvis en ny database skal oprettes \tn % Row Count 14 (+ 9) % Row 3 \SetRowColor{white} {\bf{Replikation}} & Replikation gør det muligt at distribuerer og synkronisere database objekter fra en database til en anden database \tn % Row Count 19 (+ 5) % Row 4 \SetRowColor{LightBackground} {\bf{Replikations Typer}} & {\bf{Snapshot}} – Laver en komplet replikation af data \tn % Row Count 22 (+ 3) % Row 5 \SetRowColor{white} & {\bf{Transactional}} – Ændringer af data,- samt skemaændringer foretaget hos udgiveren \tn % Row Count 26 (+ 4) % Row 6 \SetRowColor{LightBackground} & {\bf{Peer-to-Peer}} – Opretholder kopier af data på tværs af servere \tn % Row Count 29 (+ 3) % Row 7 \SetRowColor{white} & {\bf{Merge Replication}} – Ændring af data og skema uddeles med udgiveren og abonnenten \tn % Row Count 33 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.12 cm} x{4.88 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Vedligeholdes Samt Optimering}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Ressourceovervågning }} & Perfmon kan bruges til at holde øje med Processor, Disk og Netværk \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{SQL Server Profiler}} & SQL Server profiler kan holde øje med aktivitet på serveren, f.eks. hvem der laver Querys og fra hvilket program. På denne måde kan man spore hvor man skal optimere Querys \tn % Row Count 11 (+ 8) % Row 2 \SetRowColor{LightBackground} {\bf{Monitorere aktivitet }} & {\bf{Overview}} – Holder øje med processor brug, opgaver som afventer, database I/O \tn % Row Count 15 (+ 4) % Row 3 \SetRowColor{white} & {\bf{Processes}} – Holder øje med hvilken processer der kører, login og kommandoer \tn % Row Count 19 (+ 4) % Row 4 \SetRowColor{LightBackground} & {\bf{Resource Waits}} – Viser ventetiden og hvilke processer der afventer \tn % Row Count 22 (+ 3) % Row 5 \SetRowColor{white} & {\bf{Data File I/O}} – Viser information om databaserne, filer som er i brug, og deres ydeevne \tn % Row Count 26 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.04 cm} x{4.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Backup}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Full backups }} & Backs up the databases ({\emph{.edb), transaction logs (}}.log), checkpoint files (*.chk), and then truncates the transaction logs for a specific database. \tn % Row Count 7 (+ 7) % Row 1 \SetRowColor{white} {\bf{Copy backups }} & Backs up the database, transaction logs, and checkpoint files. Copy backups do not truncate the transaction logs for the database. \tn % Row Count 13 (+ 6) % Row 2 \SetRowColor{LightBackground} {\bf{Incremental backups }} & Backs up the transaction logs to record changes since the last full or incremental backup, and then truncates the transaction logs. \tn % Row Count 19 (+ 6) % Row 3 \SetRowColor{white} {\bf{Differential backups }} & Backs up the transaction logs to record changes since the last full or incremental backup, and does not truncate the transaction logs. \tn % Row Count 25 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}