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
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.
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
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