Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
19 Cards in this Set
- Front
- Back
SQL Function Categories |
- Data Definition Language - Data Manipulation Language - Database Control |
|
Creating tables
|
CREATE TABLE tableName (
field1_name data_type [constraint], field2_name data_type [constraint], ); |
|
Primary/Foreign Keys |
... PRIMARY KEY (field1_name), FOREIGN KEY (field2_name), REFERENCES (tableName2) ); |
|
SQL Constraints |
NOT NULL = duh
DEFAULT = Assigns a value to the attribute when row is created. CHECK = Validates data when a value is entered into attribute |
|
Inserting Values |
INSERT INTO TableName VALUES (field1_value, field2_value); |
|
Literal |
A constant used in SQL statements. Char's are enclosed in ' ' while numbers are not. |
|
Select Statement |
SELECT field_name1, field_name2 FROM TableName ; |
|
DISTINCT |
Eliminates duplicates. Placed after SELECT statement. (SELECT DISTINCT fieldName1) |
|
Pattern Matching |
Enclose the term to find in % symbols. eg: WHERE Address LIKE '%Sydney%' ; |
|
Update records |
UPDATE statement. UPDATE TableName SET columnName1 = dataValue1 ; |
|
Delete records |
DELETE FROM TableName; Does not delete table, only records. |
|
Multi-Table Queries |
Must use a cartesian product to join the tables. WHERE A = B and B = C and ... ; |
|
Aggregate Functions |
Includes: COUNT, SUM, AVG, MIN, MAX Select list must either be in an aggregate function or in a GROUP BY clause. |
|
View |
Dynamic result of one or more relations operating on the original relations to produce a new relation (table). Is a logical or virtual table. CREATE VIEW ViewName AS (regular select commands etc) ; |
|
Sub Queries |
A query inside a query. Typically the result of the inner query (eg. SELECT) is used as the criteria for a WHERE or HAVING clause. |
|
You can use ORDER BY in a sub query |
False. Only in the outer SELECT. |
|
You can name multiple columns in a SELECT sub query |
False. Can only name one column. |
|
Sub query in a Comparison can be used on both sides. |
False. Can only be on the right hand side. |
|
SOME and ALL |
SOME - Returns true if at least one value satisfies criteria. ALL - Returns true if all values satisfy critera. |