Section 1

Preview this deck

<> or ! =

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (168)

Section 1

(50 cards)

<> or ! =

Front

SQL operator for not equal to

Back

;

Front

Indicates SQL Statement is Complete

Back

COUNT

Front

returns the count of values in a column

Back

'%ITEM%'

Front

Contains the following word, use with LIKE in WHERE clause

Back

BETWEEN

Front

selects all keyword within a range; Used in WHERE statement

Back

ALTER TABLE celebs ADD COLUMN twitter_handle TEXT;

Front

Add a new column 'twitter_handle' to the table in TEXT format

Back

DESC

Front

sort by descending (largest on top)

Back

ALL

Front

selects all data

Back

ORDER BY

Front

optional clause to sort

Back

INSERT INTO celebs (id, name, age) VALUES (1, 'Micheal Fasbander', 38);

Front

1 is an integer that will be inserted into the id column 'Micheal Fasbander' is text that will be inserted into the name column 38 is an integer that will be inserted into the age column

Back

< =

Front

SQL operator for less than or equal to

Back

GROUP BY

Front

Gathers Data

Back

IN

Front

operator that tests whether or not a value (stated before the keyword) is part of the list of values provided after the keyword; replaces compound operator need to use AND/OR

Back

*

Front

Selects all columns to return

Back

HAVING

Front

GROUP BY clause: Satisfies a condition in "quotes", used for COUNT or plural clauses

Back

OR

Front

Join two or more conditions in the WHERE clause, at least condition must be true

Back

How to run a query to see the result?

Front

SELECT * FROM celebs;d

Back

SELECT

Front

Select columns

Back

' '

Front

Used around text strings for conditions for easier code reading and machine understanding

Back

>, <

Front

SQL operator for greater or less than

Back

FROM

Front

Choose from a table

Back

To view the row you just created, under the INSERT statement type

Front

SELECT * FROM celebs;

Back

-

Front

used for subtraction

Back

AND

Front

Joins two or more conditions in the WHERE clause; both conditions must be true

Back

SELECT name FROM celebs;

Front

SELECT statements are used to fetch data from a database. Here, SELECT returns all data in the name column of the celebs table. 1. SELECT is a clause that indicates that the statement is a query. You will use SELECT every time you query data from a database. 2. name specifies the column to query data from. 3. FROM celebs specifies the name of the table to query data from. In this statement, data is queried from the celebs table.

Back

Update the table to include Taylor Swift's twitter handle. In the code editor type:

Front

UPDATE celebs SET twitter_handle = '@taylorswift13' WHERE id = 4; SELECT * FROM celebs;

Back

___ perform specific tasks in SQL. By convention, __ are written in capital letters. ___ can also be referred to as commands. ex) CREATE TABLE

Front

Clauses

Back

DISTINCT

Front

selects unique records, discards duplicate records

Back

Add a row to the table

Front

INSERT INTO celebs (id, name, age) VALUES (1, 'Justin Bieber', 21);

Back

=

Front

SQL operator for equal

Back

WHERE

Front

create a condition from a table

Back

ASC

Front

sort by ascending (smallest on top)

Back

SUM

Front

returns the sum of values in a column

Back

MAX

Front

returns largest value in a column

Back

NOT BETWEEN

Front

To display the keyword outside the range

Back

> =

Front

SQL operator for greater than or equal to

Back

SELECT name FROM celebs;

Front

only name column shows from celebs table

Back

MIN

Front

returns smallest value in a column

Back

LIKE

Front

SQL operator for string comparison test, used in where clause

Back

COUNT(*)

Front

returns the number of rows in a table

Back

Semicolon ;

Front

Goes at the end of a SQL statement so it will execute

Back

AVG

Front

returns the average value in column

Back

+

Front

used for addition

Back

NOT IN

Front

will exclude keywords from a list

Back

CREATE TABLE celebs (id INTEGER, name TEXT, age INTEGER);

Front

1. CREATE TABLE is a clause that tells SQL you want to create a new table. 2. celebs is the name of the table. 3. (id INTEGER, name TEXT, age INTEGER) is a list of parameters defining each column in the table and its data type.

Back

parameter ex: (column_1 data_type, column_2 data_type, column_3 data_type)

Front

is a list of columns, data types, or values that are passed to a clause as an argument

Back

PRO%

Front

used for what a command starts with, located in LIKE for WHERE clause

Back

*

Front

used for multiplication

Back

()

Front

Use these types of brackets around conditions to make code easier to read

Back

LIMIT

Front

Back

Section 2

(50 cards)

NOT LIKE

Front

used to show what is not contained in the word

Back

value (1, 2, 3)

Front

Used to add data with the INSERT INTO function

Back

/

Front

used for division

Back

SIGN(x)

Front

returns the sign of input x as -1, 0, or 1 (negative, zero, or positive respectively)

Back

SELECT TOP 2/50 PERCENT

Front

Selects the first 2, or first 50 percent of data from a table

Back

set

Front

Command used to make updates to a table

Back

DELETE, where

Front

statement to remove rows from a table

Back

Ex. for INNER Join - FROM customers, items

Front

Most common join "equijoin" or where two tables data are being pulled

Back

INNER JOIN, ON

Front

Returns all rows when there is at least one match in BOTH tables

Back

Example Between Statements

Front

WHERE ProductName BETWEEN 'C' AND 'M'; BETWEEN #07/04/1996# AND #07/09/1996#;

Back

UPDATE

Front

Statement used to update records

Back

DROP table "tablename"

Front

Delete a table to start from beginning

Back

%

Front

used for modulo Boolean

Back

INSERT INTO

Front

Add Columns or data to a table INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...);

Back

_

Front

wildcard used to substitute for any single character, multiple can be combined together

Back

CREATE TABLE/Database "table name" (col1 constraint1, col2 constraint2, etc)

Front

SQL Statement to Create a new table/database

Back

FLOOR(x)

Front

returns the largest integer value that is less than or equal to x

Back

Case SenSiTive

Front

SQL is NoT Case Sensitive

Back

SQL Injection 2

Front

uName = getRequestString("UserName"); uPass = getRequestString("UserPass"); sql = "SELECT * FROM Users WHERE Name ='" + uName + "' AND Pass ='" + uPass + "'"

Back

number(size, d)

Front

Number value with a maximum number of digits of "size" total, with a maximum number of "d" digits to the right of the decimal.

Back

LEFT JOIN

Front

Return all rows from the left table, and the matched rows from the right table

Back

purchases.customer_info

Front

nomenclature used for naming tables when joins for multiple tables is present

Back

CEILING(x) or CEIL(x)

Front

returns the smallest integer value that is greater than or equal to x

Back

Not Null

Front

Constraint that specifics a column cannot be empty

Back

Select column1 AS column

Front

Aliases "AS" used to make columns more readable

Back

FULL OUTER JOIN or FULL JOIN

Front

Adds columns from one table to another by way of a join

Back

30 characters

Front

Maximum number of characters allowed for a SQL statement

Back

SQL Injection

Front

Add to webpage, like: txtUserId = getRequestString("UserId"); txtSQL = "SELECT * FROM Users WHERE UserId = " + txtUserId;

Back

Batch SQL Code

Front

Code statement; Code Statement2; Using semicolons allows multiple statements

Back

ALTER [Table, Database]

Front

modifies a table/database

Back

FROM customer_info INNER JOIN purchases

Front

Another option to write inner join

Back

MOD(x,y)

Front

modulo - returns the integer remainder of x divided by y (same as x%y)

Back

WHERE city LIKE '[a-c]%';

Front

lets you find a search with any character in a range

Back

POWER(x,y)

Front

returns the value of x raised to the power of y

Back

UPDATE, set age= age+1 where firstname="Mary"

Front

Clause used with UPDATE where you make an update to a column and then list a condition

Back

ROUND(x)

Front

returns the value of x rounded to the nearest whole integer

Back

varchar(size)

Front

Variable-length character string. Max size is specified in parenthesis.

Back

CREATE/DROP INDEX index_name ON table_name (column_name)

Front

Creates or Drops an Index as a search key

Back

char(size)

Front

Fixed-length character string. Size is specified in parenthesis. Max 255 bytes.

Back

ROUND(x,d)

Front

returns the value of x rounded to the number of decimal places specified by the value d

Back

ABS(x)

Front

returns the absolute value of x

Back

Address+

Front

Character allowed as a space for when combining phrases together

Back

Avoid SQL Injection

Front

txtNam = getRequestString("CustomerName"); txtAdd = getRequestString("Address"); txtCit = getRequestString("City"); txtSQL = "INSERT INTO Customers (CustomerName,Address,City) Values(@0,@1,@2)"; db.Execute(txtSQL,txtNam,txtAdd,txtCit);

Back

date(size)

Front

Date value

Back

SQRT(x)

Front

returns the square-root value of x

Back

CONCAT()

Front

Combines text together

Back

WHERE city LIKE '[bsp]%'; or WHERE city NOT LIKE '[!bsp]%';

Front

lets you find a search with any character beginning that is not the following

Back

WHERE city LIKE '[bsp]%';

Front

lets you select to begin with any of the following characters

Back

Primary Key

Front

A combination of a NOT NULL and UNIQUE. Ensures that a column (or combination of two or more columns) have an unique identity which helps to find a particular record in a table more easily and quickly

Back

number(size)

Front

Number value with a max number of column digits specified in parenthesis.

Back

Section 3

(50 cards)

DATEDIFF()

Front

Returns the number of days between two dates

Back

TO_DATE ( String, [Format], [Optional Setting] )

Front

Converts a Date to a string

Back

UNION ALL

Front

Combine both tables and show all duplicates

Back

SELECT * INTO newtable FROM table1 WHERE 1=0;

Front

Create a new empty table

Back

DATE_FORMAT()

Front

Displays date/time data in different formats

Back

FIRST() or TOP 1 + ASC/DESC

Front

function that returns the first value

Back

CURDATE()

Front

Returns to the current date

Back

DUAL table

Front

One row and one column

Back

CREATE SEQUENCE [name] STARTS WITH [num] ... INCREMENT BY [num]

Front

Creates a sequence with increments

Back

|

Front

Default headsep character in SQL plus

Back

ROUND()

Front

Rounds a numeric field to the number of decimals specified

Back

CURTIME()

Front

Returns the current time

Back

DESCRIBE

Front

provides context about the columns in a SQL table

Back

ISNULL(), NVL(), IFNULL(), COALESCE()

Front

function to specify how we want to treat NULL Values

Back

Join Two Tables

Front

select Salesperson.Name from Salesperson, Orders where Salesperson.ID = Orders.salesperson_id and cust_id = '4';

Back

DATE()

Front

Extracts the date part of a date or date/time expression

Back

DATE_SUB()

Front

Subtracts a specified time interval from a date

Back

INITCAP

Front

returns first character of each word upper case

Back

MID()

Front

Extract characters from a text field

Back

Data types

Front

http://www.w3schools.com/sql/sql_datatypes_general.asp http://www.w3schools.com/sql/sql_datatypes.asp

Back

TRANSLATE

Front

function that let's you change how the context is written

Back

/ /

Front

Used to comment multiple lines in SQL

Back

AUTO_INCREMENT

Front

Data type to auto increase the entries for a column in table

Back

DATE_ADD()

Front

Adds a specified time interval to a date

Back

ALTER TABLE Persons ADD CONSTRAINT uc_PersonID UNIQUE (P_Id,LastName) ALTER TABLE Persons ADD UNIQUE (P_Id)

Front

Add constraint

Back

REFERENCES

Front

points to a different column

Back

____ programming language designed to manipulate and manage data stored in relational databases.

Front

SQL

Back

EXTRACT()

Front

Returns a single part of a date/time

Back

ALTER TABLE Persons DROP CONSTRAINT/INDEX uc_PersonID

Front

Drop constraint

Back

FORMAT()

Front

Formats how a field is to be displayed

Back

Check

Front

Ensures that the value in a column meets a specific condition

Back

____ is a string of characters that the database recognizes as a valid command.

Front

A statement

Back

Insert Rows

Front

insert into highAchiever (name, age) (select name, age from salesperson where salary > 100000);

Back

UCASE()

Front

function that Converts a field to upper case

Back

column IS NULL; column IS NOT NULL;

Front

query used to search for null values

Back

Foreign key

Front

Ensure the referential integrity of the data in one table to match values in another table

Back

LCASE()

Front

function that Converts a field to lower case

Back

UNION

Front

The UNION operator is used to combine the result-set of two or more SELECT statements.

Back

TRUNCATE TABLE

Front

delete data in table, not table

Back

___ is a condition in SQL that returns true when the value is NULL and false otherwise.

Front

IS NULL

Back

Unique

Front

Ensures that each row for a column must have a unique value

Back

How dates work

Front

select User.name, User.phone_num, max(UserHistory.date) from User, UserHistory where User.user_id = UserHistory.user_id and UserHistory.action = 'logged_on' and UserHistory.date >= date_sub(curdate(), interval 30 day) group by (User.user_id);

Back

SELECT INTO

Front

statement selects data from one table and inserts it into a new table. SELECT Customers.CustomerName, Orders.OrderID INTO CustomersOrderBackup2013 FROM Customers LEFT JOIN Orders ON Customers.CustomerID=Orders.CustomerID;

Back

LAST()

Front

function that returns the last value

Back

LEN()

Front

Returns the length of a text field

Back

RIGHT JOIN

Front

Return all rows from the right table, and the matched rows from the left table

Back

Default 'Food'

Front

Specifies a default value when specified none for this column

Back

NOW()

Front

Returns the current date and time

Back

____ creates a new table.

Front

CREATE TABLE creates a new table.

Back

CREATE or REPLACE VIEW

Front

Makes a view to see data

Back

Section 4

(18 cards)

___ deletes rows from a table.

Front

DELETE FROM

Back

Tables are sometimes referred to as ---

Front

relations

Back

Common data type

Front

Integer, a positive or negative whole number Text, Date, Real (decimal points)

Back

Data Warehouse, Database, Tables, Views

Front

How data is organized in SQL Server

Back

____ queries data from a table

Front

SELECT

Back

WHERE

Front

Clause that filters SELECT * FROM movies WHERE imdb_rating > 8; clause that indicates you want to filter the result set to include only rows where the following condition is true.

Back

SELECT DISTINCT

Front

used to return unique values in the result set. It filters out all duplicate values. Here, the result set lists each genre in the movies table exactly once. 1. SELECT DISTINCT specifies that the statement is going to be a query that returns unique values in the specified column(s)

Back

_____ changes an existing table

Front

ALTER TABLE

Back

Date

Front

data type, formatted as YYYY-MM-DD for the year, month, and day

Back

Text

Front

data type, String

Back

CREATE TABLE table_name ( column_1 data_type, column_2 data_type, column_3 data_type);

Front

SQL statement that CREATEs TABLE

Back

AS

Front

renaming, AS tot_dollar #rename col as tot_dollar

Back

RDBMS

Front

Relational Database Management System

Back

Return empty values

Front

select distinct u.user_id from User as u left join UserHistory as uh on u.user_id=uh.user_id where uh.user_id is null

Back

--- edits a row in a table.

Front

UPDATE

Back

Real

Front

data type, a decimal value

Back

A ___ is a set of data values of a particular type. Here id, name, and age are each ---

Front

column

Back

____ adds a new row to a table

Front

INSERT INTO add row to table

Back