SQL Flashcards

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
Q

EXISTS

A

special operator. checks whether a subquery returns any rows

26
Q

data definition language

A

used to create new tables
does not deal with data
in some DBMSs SQL is not needed to create tables

27
Q

GROUP BY

A

Groups the selected rows based on one or more attributes.

28
Q

HAVING

A

Restricts the selection of grouped rows based on a condition

29
Q

ORDER BY

A

Orders the selected rows based on one or more attributes

30
Q

DISTINCT

A

limits values to unique values

31
Q

COUNT

A

Aggregate function. Returns the number of rows with non-null values for a given column.

32
Q

MIN

A

Aggregate function. Returns the minimum attribute value found in a given column

33
Q

MAX

A

Aggregate function. Returns the maximum attribute value found in a given column

34
Q

SUM

A

Aggregate function. Returns the sum of all values for a given column

35
Q

AVG

A

Aggregate function. Returns the average of all the values forgiven column

36
Q

CREATE SCHEMA AUTHORISATION

A

Create a database schema

37
Q

CREATE TABLE

A

Creates a new table in the user’s database schema

38
Q

NOT NULL

A

Ensures that a column will not have null values

39
Q

UNIQUE

A

Ensures that a column will not have duplicate values

40
Q

PRIMARY KEY

A

Defines a primary key for a table

41
Q

FOREIGN KEY

A

Defines a foreign key for a table

42
Q

DEFAULT

A

Defines a default value for a column (when no value is given)

43
Q

CHECK

A

Validate the data in an attribute

44
Q

CREATE INDEX

A

Create an index for a table

45
Q

CREATE VIEW

A

Create a dynamic subset of rows and columns from one or more tables

46
Q

ALTER TABLE

A

Modifies a table’s definition (ads modifies or delete attributes or constraints)
changes general structure of data (cr: UPDATE)

47
Q

CREATE TABLE AS

A

Create a new table based on a query in the user’s database schema

48
Q

DROP TABLE

A

Permanently deletes a table (and it’s data)

49
Q

DROP INDEX

A

Permanently deletes an index

50
Q

DROP VIEW

A

Permanently deletes a view

51
Q

order #1

A
INSERT
COMMIT
SELECT 
UPDATE
ROLLBACK
DELETE
INSERT + SELECT
52
Q

use brackets if you want

A

values checked in a specific order otherwise it’ll be done left to right

53
Q

if you need to check the same info in different tables (e.g. customer codes) use

A

T1.CUS_CODE = T2.CUS_CODE structure

54
Q

when copying parts of a table

A

create new part table then use INSERT INTO command

55
Q

order #2

A
SELECT 
FROM 
WHERE 
GROUP BY 
HAVING 
ORDER BY
56
Q

when you want information from multiple tables

A

you must use a join operator