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
LIKE
Front
SQL operator for string comparison test, used in where clause
Back
DESC
Front
sort by descending (largest on top)
Back
LIMIT
Front
Back
MIN
Front
returns smallest value in a column
Back
MAX
Front
returns largest value in a column
Back
HAVING
Front
GROUP BY clause:
Satisfies a condition in "quotes", used for COUNT or plural clauses
Back
To view the row you just created, under the INSERT statement type
Front
SELECT * FROM celebs;
Back
COUNT
Front
returns the count of values in a column
Back
SUM
Front
returns the sum of values in a column
Back
Semicolon ;
Front
Goes at the end of a SQL statement so it will execute
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
WHERE
Front
create a condition from a table
Back
OR
Front
Join two or more conditions in the WHERE clause, at least condition must be true
Back
___ perform specific tasks in SQL. By convention, __ are written in capital letters. ___ can also be referred to as commands. ex) CREATE TABLE
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 equal
Back
;
Front
Indicates SQL Statement is Complete
Back
SELECT name FROM celebs;
Front
only name column shows from celebs table
Back
'%ITEM%'
Front
Contains the following word, use with LIKE in WHERE clause
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
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
>, <
Front
SQL operator for greater or less than
Back
FROM
Front
Choose from a table
Back
ORDER BY
Front
optional clause to sort
Back
DISTINCT
Front
selects unique records, discards duplicate records
Back
<> or ! =
Front
SQL operator for not equal to
Back
-
Front
used for subtraction
Back
AND
Front
Joins two or more conditions in the WHERE clause; both conditions must be true
Back
PRO%
Front
used for what a command starts with, located in LIKE for WHERE clause
is a list of columns, data types, or values that are passed to a clause as an argument
Back
Section 2
(50 cards)
SQRT(x)
Front
returns the square-root value of x
Back
30 characters
Front
Maximum number of characters allowed for a SQL statement
Back
Batch SQL Code
Front
Code statement;
Code Statement2;
Using semicolons allows multiple statements
Back
CONCAT()
Front
Combines text together
Back
set
Front
Command used to make updates to a table
Back
ABS(x)
Front
returns the absolute value of x
Back
INNER JOIN, ON
Front
Returns all rows when there is at least one match in BOTH tables
Back
WHERE city LIKE '[bsp]%';
Front
lets you select to begin with any of the following characters
Back
DROP table "tablename"
Front
Delete a table to start from beginning
Back
/
Front
used for division
Back
Example Between Statements
Front
WHERE ProductName BETWEEN 'C' AND 'M';
BETWEEN #07/04/1996# AND #07/09/1996#;
Back
_
Front
wildcard used to substitute for any single character, multiple can be combined together
Back
ROUND(x)
Front
returns the value of x rounded to the nearest whole integer
Back
date(size)
Front
Date value
Back
purchases.customer_info
Front
nomenclature used for naming tables when joins for multiple tables is present
Back
INSERT INTO
Front
Add Columns or data to a table
INSERT INTO table_name (column1,column2,column3,...)
VALUES (value1,value2,value3,...);
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
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
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
SELECT TOP 2/50 PERCENT
Front
Selects the first 2, or first 50 percent of data from a table
Back
ROUND(x,d)
Front
returns the value of x rounded to the number of decimal places specified by the value d
Back
Case SenSiTive
Front
SQL is NoT Case Sensitive
Back
ALTER [Table, Database]
Front
modifies a table/database
Back
SQL Injection 2
Front
uName = getRequestString("UserName");
uPass = getRequestString("UserPass");
sql = "SELECT * FROM Users WHERE Name ='" + uName + "' AND Pass ='" + uPass + "'"
Back
Not Null
Front
Constraint that specifics a column cannot be empty
returns the largest integer value that is less than or equal to x
Back
LEFT JOIN
Front
Return all rows from the left table, and the matched rows from the right table
Back
number(size)
Front
Number value with a max number of column digits 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
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
CEILING(x) or CEIL(x)
Front
returns the smallest integer value that is greater than or equal to x
Back
SQL Injection
Front
Add to webpage, like:
txtUserId = getRequestString("UserId");
txtSQL = "SELECT * FROM Users WHERE UserId = " + txtUserId;
Back
varchar(size)
Front
Variable-length character string. Max size is specified in parenthesis.
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
%
Front
used for modulo Boolean
Back
NOT LIKE
Front
used to show what is not contained in the word
Back
Address+
Front
Character allowed as a space for when combining phrases together
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
POWER(x,y)
Front
returns the value of x raised to the power of y
Back
FULL OUTER JOIN or FULL JOIN
Front
Adds columns from one table to another by way of a join
Back
Select column1 AS column
Front
Aliases "AS" used to make columns more readable
Back
SIGN(x)
Front
returns the sign of input x as -1, 0, or 1 (negative, zero, or positive respectively)
Back
UPDATE
Front
Statement used to update records
Back
char(size)
Front
Fixed-length character string. Size is specified in parenthesis. Max 255 bytes.
Back
Section 3
(50 cards)
DATE_SUB()
Front
Subtracts a specified time interval from a date
Back
LCASE()
Front
function that Converts a field to lower case
Back
ALTER TABLE Persons
DROP CONSTRAINT/INDEX uc_PersonID
Front
Drop constraint
Back
TRANSLATE
Front
function that let's you change how the context is written
Back
ISNULL(), NVL(), IFNULL(), COALESCE()
Front
function to specify how we want to treat NULL Values
Back
NOW()
Front
Returns the current date and time
Back
DESCRIBE
Front
provides context about the columns in a SQL table
Back
Unique
Front
Ensures that each row for a column must have a unique value
Back
INITCAP
Front
returns first character of each word upper case
Back
DATEDIFF()
Front
Returns the number of days between two dates
Back
RIGHT JOIN
Front
Return all rows from the right table, and the matched rows from the left table
Back
MID()
Front
Extract characters from a text field
Back
LAST()
Front
function that returns the last value
Back
___ is a condition in SQL that returns true when the value is NULL and false otherwise.
Front
IS NULL
Back
AUTO_INCREMENT
Front
Data type to auto increase the entries for a column in table
Back
DUAL table
Front
One row and one column
Back
TRUNCATE TABLE
Front
delete data in table, not table
Back
CURTIME()
Front
Returns the current time
Back
FORMAT()
Front
Formats how a field is to be displayed
Back
UCASE()
Front
function that Converts a field to upper case
Back
|
Front
Default headsep character in SQL plus
Back
REFERENCES
Front
points to a different column
Back
____ is a string of characters that the database recognizes as a valid command.
Front
A statement
Back
Join Two Tables
Front
select Salesperson.Name from Salesperson, Orders where
Salesperson.ID = Orders.salesperson_id and cust_id = '4';
Back
FIRST() or TOP 1 + ASC/DESC
Front
function that returns the first value
Back
UNION
Front
The UNION operator is used to combine the result-set of two or more SELECT statements.
Back
Default 'Food'
Front
Specifies a default value when specified none for this column
Back
____ creates a new table.
Front
CREATE TABLE creates a new table.
Back
UNION ALL
Front
Combine both tables and show all duplicates
Back
CREATE or REPLACE VIEW
Front
Makes a view to see data
Back
LEN()
Front
Returns the length of a text field
Back
Check
Front
Ensures that the value in a column meets a specific condition
Back
column IS NULL;
column IS NOT NULL;
Front
query used to search for null values
Back
CREATE SEQUENCE [name] STARTS WITH [num] ... INCREMENT BY [num]
Front
Creates a sequence with increments
Back
DATE_ADD()
Front
Adds a specified time interval to a date
Back
CURDATE()
Front
Returns to the current date
Back
DATE()
Front
Extracts the date part of a date or date/time expression
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;
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
ALTER TABLE Persons
ADD CONSTRAINT uc_PersonID UNIQUE (P_Id,LastName)
ALTER TABLE Persons
ADD UNIQUE (P_Id)
Front
Add constraint
Back
Insert Rows
Front
insert into highAchiever (name, age)
(select name, age from salesperson where salary > 100000);
Back
EXTRACT()
Front
Returns a single part of a date/time
Back
Foreign key
Front
Ensure the referential integrity of the data in one table to match values in another table
Back
DATE_FORMAT()
Front
Displays date/time data in different formats
Back
ROUND()
Front
Rounds a numeric field to the number of decimals specified
Back
SELECT *
INTO newtable
FROM table1
WHERE 1=0;
Front
Create a new empty table
Back
____ programming language designed to manipulate and manage data stored in relational databases.
Front
SQL
Back
Section 4
(18 cards)
--- edits a row in a table.
Front
UPDATE
Back
____ queries data from a table
Front
SELECT
Back
RDBMS
Front
Relational Database Management System
Back
____ adds a new row to a table
Front
INSERT INTO add row to table
Back
Common data type
Front
Integer, a positive or negative whole number
Text, Date, Real (decimal points)
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
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
AS
Front
renaming, AS tot_dollar #rename col as tot_dollar
Back
A ___ is a set of data values of a particular type. Here id, name, and age are each
---
Front
column
Back
Data Warehouse, Database, Tables, Views
Front
How data is organized in SQL Server
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
Date
Front
data type, formatted as YYYY-MM-DD for the year, month, and day