Section 1

Preview this deck

Exception1

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 (83)

Section 1

(50 cards)

Exception1

Front

You cannot, except in certain cases, combine a built-in function with another column name in the SELECT statement

Back

SUM

Front

We can obtain this from a particular column by performing a query like this: Ex: SELECT SUM(OrderTotal) FROM RETAIL_ORDER;

Back

How the GROUP BY Clause Works

Front

The DBMS sorts rows according to the condition set forth in the GROUP BY and then counts the number of rows with the same value in that condition

Back

Exception2

Front

You cannot use SQL built-in functions in the WHERE clause

Back

WHERE Clause

Front

In order to use this, we would simply add a column to limit on and then the row value that we want Ex: SELECT * FROM Employee WHERE EmployeeLastName = 'Smith';

Back

ALTER TABLE

Front

- We can change an existing table to add, delete or change columns and/or constraints - Additionally, we can also add or modify constraints - ADD CONSTRAINT and DROP CONSTRAINT

Back

Column Order

Front

The order in which you include your columns in your query will also dictate the order of the columns in your result set

Back

JOINS

Front

- Pulling information from multiple tables in the database

Back

Wildcards

Front

There may be cases where we want to return records that are only dependent on a portion of the data being searched In order to write this, we would use a % character in the query. We also need to change the column = to column LIKE Ex: SELECT * FROM SKU_DATA WHERE Buyer LIKE 'Pete%';

Back

INSERT Statement

Front

- This statement is used to add rows of data to table

Back

IN / NOT IN

Front

We can use these to shorten the query length and still achieve the same result Ex: SELECT EmployeeID FROM EMPLOYEE WHERE EmployeeLastName IN ('Smith','Phillips'); You can also exclude these results by adding the keyword NOT in front of IN

Back

Specific Queries

Front

We can also narrow columns and rows in our query by simply using the following structure: Ex: SELECT SKU_Description, Department FROM SKU_DATA WHERE Department = 'Climbing';

Back

Concatenation

Front

We can use the + symbol to do this to the results in the SELECT statement to be provided as a single result in the result set Ex: SELECT Buyer +'in' + Department AS Sponsor;

Back

CREATE TABLE

Front

- The SQL command used to create a database table

Back

Built-In SQL Functions

Front

1) SUM 2) AVG 3) MIN 4) MAX 5) COUNT

Back

OUTER JOIN

Front

- This type of join returns all rows from both tables, and includes matches in the same row

Back

ON UPDATE / ON ACTION

Front

- If we have a foreign key reference in a table, we may want to prevent changes from being made if the primary key in the parent table is changed... - We can do this by using ON UPDATE NO ACTION, ON DELETE NO ACTION - If for some reason we want the change to propagate through both tables, we would use ON UPDATE CASCADE, ON DELETE CASCADE

Back

INNER JOIN

Front

- Allows us to pull rows from Table A where Table B contains matching rows

Back

DROP TABLE

Front

- This SQL statement will delete the table from the database and the data continued within the table - Ex: DROP TABLE ORDERS; - If you have any foreign key constraints that references the table, you will not be able to execute the DROP. You will need to DROP the table with the constraint and then the parent table.

Back

CROSS JOIN

Front

- This join is the equivalent of the Cartesian product between two tables, Table A and Table B

Back

Limiting Rows

Front

- Suppose that we want to retrieve all columns from a particular table, but we do not want all of the rows contained - We can use another portion of the basic framework known as the WHERE clause Ex: SELECT * FROM Employee WHERE...

Back

SQL/Persistent Stored Modules (SQL/PSM)

Front

These statements extend SQL by adding the ability to do procedural programming, including the use of variables and flow-of-control statements

Back

Wildcard (*)

Front

In order to select all of the columns within a particular table, we can use this special character in place of listing each column

Back

Calculations In SELECT

Front

We can perform these in the SELECT statement, such as multiplying Quantity and Price together to get ExtendedPrice Ex: SELECT Quantity * Price AS EP FROM ORDER_ITEM;

Back

Data Control Language (CL)

Front

Statements that grant or revoke permissions to users and groups so that those users and groups can perform operations on the database

Back

Ranges

Front

BY using the BETWEEN keyword we can accomplish this The result set will include records that match the lower and upper boundaries, as well as those that are in between Ex: SELECT * FROM ORDER_ITEM WHERE ExtendedPrice BETWEEN 100 AND 200;

Back

TRUNCATE TABLE statement

Front

_ This SQL statement allows you to clear all data out of a table without destroying the table structure - You cannot specify a WHERE clause in this statement - You cannot use this where there is a foreign key constraint because it would break the link between the two tables

Back

DISTINCT Keyword

Front

In cases where you want a single, unique value, use this keyword in your query

Back

GROUP BY Clause

Front

We can use this clause to sort and consolidate the data within a particular table

Back

COUNT Function

Front

This will count the number of rows provided in the query result set

Back

Compound Clauses

Front

1) AND Operator 2) OR Operator 3) IN / NOT IN

Back

Data Extracts

Front

- In order to extract data from a database, we can use SQL, or Structured Query Language

Back

UPDATE Statement

Front

- This statement is used when we need to perform data updates within a table - Caution: You need to make sure that the update is focused in on a particular data set and not multiple rows unless that is your intention

Back

Data Manipulation Language (DML)

Front

Statements used for querying, inserting, modifying and deleting data

Back

RIGHT JOIN

Front

- This join returns all rows from Table B and also matching rows from Table A

Back

FROM

Front

Specifies the tables to be used in the query

Back

SELECT

Front

Selects the columns to be listed in the results of the query

Back

Transaction Control Language (TCL)

Front

Statements that control transaction behavior

Back

LEFT JOIN

Front

- This join returns all rows from Table A (left side), and also returns matching rows from Table B

Back

AND Operator

Front

This gives us the ability to add two or more restrictions on the result set Ex: SELECT * FROM SKU_DATA WHERE Department = 'Water Sports' AND Buyer = 'Nancy Meyers';

Back

SQL Statement Categories

Front

1) DDL 2) DML 3) SQL/PSM 4) TCL 5) DCL

Back

Database Schema

Front

A complete logical view of the database

Back

Compound WHERE Clauses

Front

1) Compound Clauses 2) Ranges 3) Wildcards

Back

Data Definition Language (DDL)

Front

Statements used for creating tables, relationships and other structures

Back

SQL Comments

Front

In order to add this in SQL, simply contain within /* and */

Back

WHERE

Front

Specifies the rows that should be included in the results of the query

Back

AS Keyword

Front

We can use this to provide a name for the result column in our table

Back

ORDER BY

Front

- The ORDER BY clause defaults the results set in ascending order - In order to enforce the particular method of sorting after specifying the column, use the keywords ASC or DESC - Ex: SELECT OrderID, OrderAmount FROM ORDERS ORDER BY OrderID DESC

Back

OR Operator

Front

There may be cases where we want to be less restrictive on the result set Ex: SELECT * FROM SKU_DATA WHERE Department = 'Camping' OR Department = 'Climbing';

Back

SELECT / FROM / WHERE Framework

Front

The most basic form of SQL queries

Back

Section 2

(33 cards)

DATE FUNCTION

Front

- In order to retrieve and insert dates, we can utilize the TO_DATE function

Back

Two Types of Locks:

Front

1) Explicit locks 2) Implicit locks

Back

Pessimistic Locking

Front

- A state where we assume a conflict will occur in the database and explicit locks are issued

Back

Lock Granularity

Front

- This determines the size of the lock and how it is applied

Back

Reasons For Having Views:

Front

1) Hide columns or rows 2) Display results of computations 3) Hide complicated SQL syntax 4) Layer built-in functions 5) Provide level of isolation between table data and users' view of data 6) Assign different processing permissions to different views of the same table 7) Assign different triggers to different views of the same table

Back

Concurrency Control

Front

- When utilizing a database, we have to look at how one event on the system can interfere with another event that is going on - We have to be careful about protecting data integrity, which can be at risk unless proper concurrency controls are in place

Back

Atomic Transactions

Front

- Transactions are sometimes referred to as logical units of work - The purpose of having transactions in place is so that if one element fails, the whole unit fails. If all of the elements succeed, then the transaction succeeds - This prevents some changes from being committed to the database while others do not - We would group statements needed for a particular action within a transaction

Back

SQL User Defined Functions

Front

- SQL statements that can be called when needed to perform a pre-defined set of actions - Allows other SQL statements to utilize the function

Back

Resource Locking

Front

- Database locks can help prevent issues such as the Lost Update Problem

Back

VIEWS- Computed Columns

Front

- ??

Back

INTERSECT

Front

- Allows us to see where two particular record sets match

Back

Configuration Control

Front

- When changes need to be made to an existing database, the database administrator is responsible for making sure that the changes are executed correctly and that there is a recovery plan in place in case anything happens - Usually this is accomplished through some sort of change control process where the information is documented

Back

SQL percent sign(%) wildcard character

Front

- The standard SQL wildcard character used to specify multiple characters

Back

DELETE Statement

Front

- We can use this statement to delete records from our database tables - In order to do this, use the WHERE clause and make sure all conditions are specified

Back

CurrVal Statement

Front

- This allows us to retrieve the current value of the sequence

Back

MINUS

Front

- Allows us to take one result set, and then subtract another result set to determine the remaining result set

Back

UNION ALL

Front

- Very similar to UNION but duplicate records are preserved

Back

Concurrent Transactions

Front

- While it may not appear this way to the user, transactions are not executed simultaneously. Rather, they are interleaved

Back

NextVal Statement

Front

- This is used by placing the column name followed by .NextVal within the insert statement

Back

Table Aliases

Front

- You can shorten the name of a table in your SQL statement by using this

Back

VIEWS

Front

- A picture of data that is created using SQL statements that pull data from one or many tables

Back

UNION

Front

- In SQL, we have the ability to combine results sets together - In order to do this, we use the UNION statement in between two SELECT statements - This statement will eliminate duplicate records

Back

Deadlock Prevention

Front

- Two methods to avoid this: 1) Optimistic Locking 2) Pessimistic Locking

Back

Implicit Locks

Front

- These are managed by the DBMS

Back

SEQUENCES

Front

- We can use this to create surrogate key values in Oracle - This allows us to keep increasing the primary key value on each insert

Back

Database Administrators

Front

- Better known as DBA's - Tasks include: 1) Manage database structure 2) Control concurrent processing 3) Manage processing rights and responsibilities 4) Develop database security 5) Provide for database recovery 6) Manage the DBMS 7) Maintain the data repository

Back

Lost Update Problem

Front

- When we have SQL statements that are running at the same time against the same records, we can run into issues - This is one of them

Back

Metadata

Front

Data that describes the data held in the database

Back

NextVal Statement and CurrVal Statement

Front

- We can utilize these two components in order to use the sequence value for our SQL statements

Back

Transaction Control Language

Front

- Three major components: 1) SET TRANSACTION- defines the start of the transaction 2) COMMIT- save the changes to the database if everything was successful 3) ROLLBACK- discard the changes made to the database if any error occurred

Back

Explicit Locks

Front

- These are defined by command

Back

Optimistic Locking

Front

- A state where we assume that there will be no conflict - Allows locks to be released faster and can increase database performance - If a conflict does occur, the transaction is repeated until it completes successfully

Back

Deadlock

Front

- A condition when two competing events need resources that the other had locked

Back