\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{iddd} \pdfinfo{ /Title (sql.pdf) /Creator (Cheatography) /Author (iddd) /Subject (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}{A31C3B} \definecolor{LightBackground}{HTML}{F9F0F2} \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 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{iddd} via \textcolor{DarkBackground}{\uline{cheatography.com/197744/cs/41798/}}} \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}iddd \\ \uline{cheatography.com/iddd} \\ \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 29th December, 2023.\\ 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} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Very basic introduction}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Databases are organized collections of information or data. They can be non-relaitonal (MongoDB, Oracle NoSQL) or relational (MySQL, Microsoft SQL Server, Oracle Database). \newline % Row Count 4 (+ 4) {\bf{Non-relational}} databases store data in a non-tabular form and tend do be more flexibnle than the traditional relational databases. They are often used when large quantities of complex and diverse data neds to be organized. There are 4 major types of NoSQL databases: document databases, key-value databases, wide-column stores, graph databases. \newline % Row Count 11 (+ 7) {\bf{Relational databases}} is a structure databasethat contians tables related to each other through keys. \newline % Row Count 14 (+ 3) -Primary keys: unique identifiers therefore cannot have duplicates or null values. \newline % Row Count 16 (+ 2) -Foreign keys: column in a table that it's the primary key in another table. \newline % Row Count 18 (+ 2) This document will focus on relational DB. \newline % Row Count 19 (+ 1) {\bf{Query}} is a request for data. Nearly all relational databases rely on a version of SQL to query data. \newline % Row Count 22 (+ 3) Types of queries: \newline % Row Count 23 (+ 1) - DDL (data definition language) \newline % Row Count 24 (+ 1) - DQL (data query language) \newline % Row Count 25 (+ 1) - DML (data manipulation language) \newline % Row Count 26 (+ 1) - DCL (data control language) \newline % Row Count 27 (+ 1) - TCL (transaction control language)% Row Count 28 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{1.2 cm} x{6.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Relational Algebra symbols}} \tn % Row 0 \SetRowColor{LightBackground} ⊥ & null \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} ∪ & reunion \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} ∩ & intersection \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} * & cartesian product \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} Π & projection \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} σ & selection \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} ⋈ & junction \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} ⋉ & semi-junction \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{∪ reunion -{}-\textgreater{} all; ∩ intersection -{}-\textgreater{} middle ones; Π projection -{}-\textgreater{} cuts columns; σ selection -{}-\textgreater{} filters lines; ⋈ junction -{}-\textgreater{} joins tables \newline \newline Eg: \newline \textasciicircum{}Π\textasciicircum{}BI, sigla {[}\textasciicircum{}σ\textasciicircum{}Quota\textgreater{}20\textasciicircum{}Sigla \textless{}\textgreater{}'KB' (Pratica){]} -{}-\textgreater{} The BI and Siglas of all the sports (table Prativa) that cost more than 20, except KB. \newline \textasciicircum{}Π\textasciicircum{}Nome{[}\textasciicircum{}σ\textasciicircum{}sigla = 'KB' (Sócios ⋈ Pratica){]} -{}-\textgreater{} name of all the people who do KB. \newline \newline https://docs.google.com/document/d/1\_70GykfmTwcu9TJ6Ji5um-Ixg2A7\_VT2/edit} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{DQL Joining tables}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/iddd_1703789592_sql.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Tables are joined by a commun column (SELECT columns, FROM table1 INNER JOIN table 2 ON \seqsplit{table1.column=table2.column)} \newline \newline For {\bf{reunion}}: (SELECT columnname FROM tablename) UNION (SELECT columname FROM table2name) \newline \newline For {\bf{intersection}} (SELECT columname FROM tablename) INTERSECT (SELECT columname FROM table2name) \newline \newline On access: - use NATURAL JOIN (for inner join); \newline \newline Image source: \seqsplit{https://www.reddit.com/r/SQL/comments/2zb1i0/sql\_server\_join\_types\_poster\_version\_2/}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{BD Example}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/iddd_1703021556_bd gym.png}}} \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}{DDL}} \tn % Row 0 \SetRowColor{LightBackground} CREATE TABLE tablename (columnname type columnrestriction, columnmae2 type columnrestriction, ...); & creates a table \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} CREATE INDEX name ON tablename(column asc, column desc,...); & explicit creation of index (for efficiency for ex). Unique and primary keys will automatically create indexes! \tn % Row Count 11 (+ 6) % Row 2 \SetRowColor{LightBackground} DROP TABLE tablename & deletes tables if there are no references to thi table ou if these specify ON DELETE CASCADE. In this case, it deletes the table and all the reference lines on the other tables that refer to the deleted table \tn % Row Count 22 (+ 11) % Row 3 \SetRowColor{white} CREATE VIEW & creates a view that can be used as a table \tn % Row Count 25 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\bf{Types}}:varchar2(n) = string of n characters variable size 1\textless{}4000, char(n) = string of n characters fixed size 1\textless{}255, number(p,s), date, timestamp... \newline {\bf{Column restrictions}}: none, primary key, not null,unique, references, check. {\bf{Table restrictions}}: primary key(col, col...), foreign key(col,col..), check, references. All these depend on the db.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{0.988 cm} x{3.344 cm} x{3.268 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{DML}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Insertion} & INSERT INTO tablename VALUES(val, val, val...) & adds a line with all the values in the specified order \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} & INSERT INTO tablenam(col,col...) VALUES(val,val...) & adds a line only with the values for the specificed columns \tn % Row Count 8 (+ 4) % Row 2 \SetRowColor{LightBackground} \seqsplit{Modification} & UPDTAE tablename SET col1=expr1, col2=exprs2 WHERE cond & all the lines that meet the cond have the col1 and col2 updated ccroding to the exr1 and expr2 \tn % Row Count 14 (+ 6) % Row 3 \SetRowColor{white} \seqsplit{Deletition} & DELETE FROM tablename WHERE cond & deletes all the line in the table that meet the cond \tn % Row Count 18 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{8.4cm}}{The changes stay in a temporary state. To {\bf{commit}} them permanently execut COMMIT. To {\bf{undo}} the changes after the last commit do ROLLBACK. \newline \newline It's possible to create {\bf{sequences}} to automatically create values.Eg:create sequence num\_socio start with 1000 increment by 10;insert into sócios values( num\_socio.nextval, 'Quim' );select num\_socio.currval from dual; -{}-\textgreater{} Crie uma sequência para gerar automaticamente números de sócios} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{UML to SQL}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/iddd_1703012217_bd final.png}}} \tn \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}{Operators, Patterns \& Symbols}} \tn % Row 0 \SetRowColor{LightBackground} + & plus \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} - & minus \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} * & times \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} / & divided \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} || & concatenation \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} = & equal to \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \textless{}\textgreater{} & different \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} != & different \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} \textgreater{} & greater than \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} \textless{} & less than \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} \textgreater{}= & greater than or equal to \tn % Row Count 11 (+ 1) % Row 11 \SetRowColor{white} \textless{}= & less than or equal to \tn % Row Count 12 (+ 1) % Row 12 \SetRowColor{LightBackground} {[}not{]} in & belongs {[}doesn't belong{]}{]} \tn % Row Count 14 (+ 2) % Row 13 \SetRowColor{white} {[}not{]} between x and y & x \textless{}= value \textless{}= y {[}not{]} \tn % Row Count 16 (+ 2) % Row 14 \SetRowColor{LightBackground} x {[}not{]} like y & compares x to y \tn % Row Count 17 (+ 1) % Row 15 \SetRowColor{white} is {[}not{]} null & is{[}n't{]} null \tn % Row Count 18 (+ 1) % Row 16 \SetRowColor{LightBackground} not & not \tn % Row Count 19 (+ 1) % Row 17 \SetRowColor{white} and & and \tn % Row Count 20 (+ 1) % Row 18 \SetRowColor{LightBackground} or & or \tn % Row Count 21 (+ 1) % Row 19 \SetRowColor{white} * & everything/all \tn % Row Count 22 (+ 1) % Row 20 \SetRowColor{LightBackground} \_ & any letter (only 1) \tn % Row Count 23 (+ 1) % Row 21 \SetRowColor{white} \% & any sequence of characters \tn % Row Count 25 (+ 2) % Row 22 \SetRowColor{LightBackground} ( ) & fits queries inside other queries \tn % Row Count 27 (+ 2) % Row 23 \SetRowColor{white} distinct & eliminates duplicate rows \tn % Row Count 29 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{' ' - use for words \newline \newline 'M\%' = Marina, M... \newline \newline 'M\_r\%' = Mar, Mari, Moreira... \newline \newline 'a\_\_' = ant, add, alc.... \newline \newline On Microsoft Access use {\emph{ (instead of \%) and ? (instead of \_) \newline \newline {\bf{Order of precedence}}: \newline 1. Arithmetic operators (+ and - \textgreater{} }} and / \textgreater{} ||) \newline 2. Comparasion operators \newline 3. Logic operators (not \textgreater{} and \textgreater{} or) \newline \newline ( ) -{}-\textgreater{} SELEC by, salario FROM orienta WHERE salario = (SELECT max(salario) FROM orienta);} \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}{DQL Basics}} \tn % Row 0 \SetRowColor{LightBackground} SELECT rowname(s) FROM table name & displays all the info from the table on the row(s) \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} SELECT x FROM y WHERE anycriteria & displays all the x info, from table y, that meets the criteria \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} SELECT x FROM y WHERE criteria1 AND criteria2 & diplays all the x info from table y, that meets the criteria 1 and 2 \tn % Row Count 11 (+ 4) % Row 3 \SetRowColor{white} SELECT x, j FROM y ORDER BY j & displays all the x and j row's info, from y table, ordered by j \tn % Row Count 15 (+ 4) % Row 4 \SetRowColor{LightBackground} SELECT x, i FROM y GROUP BY x & displays the x and i info from table y, organized by x groups \tn % Row Count 19 (+ 4) % Row 5 \SetRowColor{white} SELECT x, i FROM y GROUP BY x HAVING criteria & displays the x and i info from table y that fits the criteria, organized by the x. \tn % Row Count 24 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{ORDER BY applies to strings (alphabetically) and numbers (asc), and applies for more than one rows. Use {\bf{desc}} to order backwards (SELECT x, j, i FROM y ORDER BY i, j desc). \newline GROUP BY organizes rows by a specific column. \newline {\bf{Example:}} SELECT id, avg(classification) as grade FROM students GROUP BY id -{}-\textgreater{} will calculate the average classification by id, taking that into account for the result on the grades column for ids that appear more than once.} \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}{DQL Simple calculations}} \tn % Row 0 \SetRowColor{LightBackground} SELECT avg(columnname) as newcolumnname FROM tablename & displays the average result of the numbers in the column of the table chosen in a new columns called newcolumnname \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} SELECT count & displays the number of rows on columname \tn % Row Count 8 (+ 2) % Row 2 \SetRowColor{LightBackground} SELECT sum & displays the addition of the numbers on the row \tn % Row Count 11 (+ 3) % Row 3 \SetRowColor{white} SELECT max & displays the higher number on the column \tn % Row Count 13 (+ 2) % Row 4 \SetRowColor{LightBackground} SELECT min & displays the smaller number \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{All of these can be used together (SELECT avg(x) as newname1, max(x) as newname2 FROM tablename;). \newline \newline These are useful for as an example finding the average (avg) of a column, to count the total of rows of a column (count), the total of the values (sum) and the max and min numbers.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.6 cm} x{4.4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{DQL - others}} \tn % Row 0 \SetRowColor{LightBackground} rownum & n. of the row for the resulting table \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} rowid & internal ddress for the row/line on the db \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} case -{}-{}- when -{}-{}- else -{}-{}- end as & turns quantitative results into qualitative \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} nvl(valuex, valueIfNule) & returns 'valuex' if it's not null and valueIfNule if valuex is null \tn % Row Count 10 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{eg:SELECT rownum, rowid, column1, column3 FROM table; and "SELECT columnname, column2name, CASE column3name WHEN n. THEN 'expression' WHEN othern. THEN 'otherexpression' ELSE 'anotherexpression' END AS newcolumnname FROM table; {\bf{Rownum}} limits results to the first n lines for extensive outputs, while {\bf{rowid}} allows quick access but is affected by import/export operations. {\bf{NVL}} is also used as NVL(t, s, n), returning S if T is positive, otherwise N.} \tn \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}{DCL}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{GRANT privilegetype (col1, col2) ON tablename TO username WITH grantoption} \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Types of privilege: alter, delete, execute, index, insert, read, references, select, update, create session, alter sesson, drop any table. Thrse apply to tables, viws, sequences, functions, packages, system and/or users.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Tehcnical support position}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{What type of queries are the most common on a technical support role? In this role, the most commonly used queries often involve retrieving and updating information related to users, tickets, issues, and system logs; data retrieval and correction; account management; configuration changes; audit trail analysis; performance tunign; report generation; data import/export issues. Egs: \newline % Row Count 8 (+ 8) 1- Retrieve ticket information: SELECT * FROM tickets WHERE ticket\_id = 'XYZ' \newline % Row Count 10 (+ 2) 2- Updtate ticket status: UPDATE tickets SET status = 'closed' WHERE ticket\_id = 'XYZ' \newline % Row Count 12 (+ 2) 3. Review system logs to identify patterns or isues affecting multiple users. SELECT * FROM system\_logs WHERE log\_type = 'Error' ORDER BY timestamp DESC LIMIT 10 \newline % Row Count 16 (+ 4) 4. Track user activity and interactions withthe system for troubleshooting purposes. SELECT * FROM user\_activity WHERE user\_id = 'ABC' ORDER BY timestamp DESC LIMIT 10 \newline % Row Count 20 (+ 4) 5. Update user information. UPDATE users SET email = 'new\_email@example.com' WHERE user\_id = 'ABC' \newline % Row Count 22 (+ 2) 6. Check the status of a service. SELECT * FROM service\_sttaus WHERE status = 'Down'; \newline % Row Count 24 (+ 2) 7. Retrieve FAQ information from a knowledge base or faq database to provide quick solutions to common issues. SELECT * FROM faq WHERE category ='Triubleshooting'. \newline % Row Count 28 (+ 4) 8. User authentication issues: check if user's credentials are valid. SELECT * FROM users WHERE username ='user123' AND password= ' hashed\_password' \newline % Row Count 31 (+ 3) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Tehcnical support position (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{9. Reset user passwords. UPDATE users SET password = 'new\_hshed\_password' WHERE username = 'user123' \newline % Row Count 3 (+ 3) 10. Check system resource usage: monitor resource usage to identify potencial performance issues. SELECT * FROM system\_resources WHERE resource\_type = 'cpu' AND usage\_percentage \textgreater{} 90; \newline % Row Count 7 (+ 4) 11. Check recent system updates. SELECT * FROM system\_updates ORDER BY update\_date DESC LIMIT 10% Row Count 9 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}