Chapter 5 Flashcards
(22 cards)
Aggregate Functions
For calculating and summarizing values in queries, SQL provides the following aggregate functions:
- COUNT
- SUM
- AVG
- MIN
- MAX
Alias
A name that is not one’s true name
COUNT
returns the number of cells in a range that contains numbers
CREATE TABLE
Used for creating and connecting relational tables
CREATE VIEW
In SQL, a view is a virtual table based on the result-set of an SQL statement. A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database. You can add SQL functions, WHERE, and JOIN statements to a view and present the data as if the data were coming from one single table.
CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
Data Control Language
Used for data access control
Data Manipulation Language
Used to insert, modify, delete, and retrieve data
- Example commands
- insert into
- update
- delete
- select
Data Definition Language
Used to create and modify the structure of the database:
- create
- alter
- drop
DELETE
to erase, wipe out, cut out
DROP TABLE
Used to remove a table from the database
INSERT INTO
used to populate the created relations with data
SELECT
used for the retrieval of data from the database relations
- most commonly issued SQL statement
- Basic form:
- SELECT <columns></columns>
- FROM <table>
DISTINCT
Can be used in conjunction with the SELECT statement
ORDER BY
Used to sort the results of the query by one or more columns (for expressions)
LIKE
Used for retrieval of records whose values partially match a certain criteria
Query
automatically execute SQL statements as soon as a page or widget loads
SQL Data Types
Each column of each SQL created relation has a specified data type
- CHAR
- VARCHAR
- INT
- NUMERIC
- DATE
SQL Standard
SQL became the standard language for querying data contained in the relational database
SUM
an Aggregate Function used to find the sum of all non-NULL values in a column
UPDATE
allows you to change the values in records using the UPDATE SQL command
VIEW
a SQLite statement that is stored in the database with an associated name
WHERE
used to specify a condition while fetching the data from one table or multiple tables