SQL Flashcards

(56 cards)

1
Q

Structured Query Language

A

Simple programming language with less than 100 words syntax which is used to manipulate data stored in a database. It gets its name from the specific order in which queries and subqueries are given and executed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

INSERT

A

Adding table rows. Can violate key constraints, including:
Primary key entered that already exists
Primary key is null
Foreign key entered that does not correspond to a primary key in another table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

COMMIT

A

Saving table changes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

SELECT

A

Listing table rows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

UPDATE

A

Updating table rows, modify data in table using UPDATE SET WHERE
Changes specific data within a table/database (cr: ALTER)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

ROLLBACK

A

Restoring table contents to state prior to changes (since last COMMIT)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

DELETE

A

Deleting table rows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

INSERT + SELECT

A

Inserting table rows with a select subquery, copying rows from one table into another

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

NULL

A

Used with INSERT when a cell value is missing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

FROM

A

applies query to specific table within database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

WHERE

A

used to apply conditional restrictions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

=

A

equal to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

>

A

greater than

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
A

less than

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

> =

A

greater than or equal to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

<=

A

less than or equal to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

<> or !=

A

not equal to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

SELECT
FROM
WHERE

A

Select with: equality comparisons, not equal to, restriction, comparison on characters, date comparison, statement with a computed column, statement with computed column and an alias,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Arithmetic Operators: The Rule of Precedence(which operator goes first ?)‏

A

Perform operations within parentheses
Perform power operations
Perform multiplications and divisions
Perform additions and subtractions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

OR/AND/NOT

A

Logical operator. Used in conditional expressions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

BETWEEN

A

special operator. checks whether an attribute value is within a range

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

IS NULL

A

special operator. checks whether an attribute value is null

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

LIKE

A

special operator. checks whether an attribute value matches a given string pattern

24
Q

IN

A

special operator. checks whether an attribute value matches any given value within a list

25
EXISTS
special operator. checks whether a subquery returns any rows
26
data definition language
used to create new tables does not deal with data in some DBMSs SQL is not needed to create tables
27
GROUP BY
Groups the selected rows based on one or more attributes.
28
HAVING
Restricts the selection of grouped rows based on a condition
29
ORDER BY
Orders the selected rows based on one or more attributes
30
DISTINCT
limits values to unique values
31
COUNT
Aggregate function. Returns the number of rows with non-null values for a given column.
32
MIN
Aggregate function. Returns the minimum attribute value found in a given column
33
MAX
Aggregate function. Returns the maximum attribute value found in a given column
34
SUM
Aggregate function. Returns the sum of all values for a given column
35
AVG
Aggregate function. Returns the average of all the values forgiven column
36
CREATE SCHEMA AUTHORISATION
Create a database schema
37
CREATE TABLE
Creates a new table in the user's database schema
38
NOT NULL
Ensures that a column will not have null values
39
UNIQUE
Ensures that a column will not have duplicate values
40
PRIMARY KEY
Defines a primary key for a table
41
FOREIGN KEY
Defines a foreign key for a table
42
DEFAULT
Defines a default value for a column (when no value is given)
43
CHECK
Validate the data in an attribute
44
CREATE INDEX
Create an index for a table
45
CREATE VIEW
Create a dynamic subset of rows and columns from one or more tables
46
ALTER TABLE
Modifies a table's definition (ads modifies or delete attributes or constraints) changes general structure of data (cr: UPDATE)
47
CREATE TABLE AS
Create a new table based on a query in the user's database schema
48
DROP TABLE
Permanently deletes a table (and it's data)
49
DROP INDEX
Permanently deletes an index
50
DROP VIEW
Permanently deletes a view
51
order #1
``` INSERT COMMIT SELECT UPDATE ROLLBACK DELETE INSERT + SELECT ```
52
use brackets if you want
values checked in a specific order otherwise it'll be done left to right
53
if you need to check the same info in different tables (e.g. customer codes) use
T1.CUS_CODE = T2.CUS_CODE structure
54
when copying parts of a table
create new part table then use INSERT INTO command
55
order #2
``` SELECT FROM WHERE GROUP BY HAVING ORDER BY ```
56
when you want information from multiple tables
you must use a join operator