Midterm Flashcards

1
Q

Definition: A logical collection of database objects

A

Schema

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

What keyword eliminated duplicates?

A

DISTINCT

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

What is the maximum number of columns you can ORDER BY?

A

246

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

By default, ORDER BY is ________

A

Ascending

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

What keyword is used to create an alias?

A

AS

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

T/F: SQL is not case sensitive.

A

TRUE

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

What is the default format for dates?

A

YYYY-MM-DDTHH:MM:SS:FF

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

What function returns the current date timestamp?

A

GetDate()

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

What keyword is used to find data from one date to another?

A

BETWEEN

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

If you want to avoid using multiple OR statements, what keyword can be use?

A

IN

ex. WHERE province IN (‘ON’, ‘BC’)

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

What operator is “not equals”

A

<> OR !=

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

Which keyword is used when specifying a pattern?

A

LIKE

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

When using LIKE, what does the % mean?

A

Any number of characters

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

How do you test for NULL?

A

The keyword IS

ex. IS NULL
ex. IS NOT NULL

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

What order are logical operators tested in?

A

NOT, AND, OR

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

What is returned if you omit an INNER JOIN or an EQUI-JOIN?

A

Cartesian Product

ex. FROM products, customers

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

Why is it bad to use an equality join?

A

Ambiguity leads to weird results

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

What keyword can be used to find the cartesian product?

A

CROSS JOIN

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

How many INNER JOINs are needed for “n” number of tables?

A

n-1

20
Q

What is DML?

A

Data Manipulation Language

21
Q

What is DDL?

A

Data Definition Language

22
Q

What is DCL?

A

Data Control Language

23
Q

When creating tables, how many characters can be in the name?

A

1-128

24
Q

Why are you able to make a table without a Primary Key specified?

A

Artificial Key

25
Q

What is an artificial key?

A

A hidden key made up of a physical address (page# + fileid)

26
Q

What keyword is used to delete a table?

A

DROP

27
Q

What keyword is used to make a table?

A

CREATE

28
Q

How many characters can a VARCHAR be?

A

8000

29
Q

What is a VARCHAR datatype?

A

Variable length string

30
Q

What’s the difference between VARCHAR and CHAR?

A

CHAR adds padding to unused space

31
Q

How do you specify an apostrophe when specifying a CHAR variable?

A

Two single quotes, NOT a double quote

32
Q

How many bits in an INT?

A

32

33
Q

How do you get the data dictionary?

A

INFORMATION_SCHEMA.

34
Q

What is a data dictionary?

A

Metadata on the database

35
Q

How do you create a table with a SELECT statement?

A

SELECT column INTO new_table FROM existing_table

36
Q

What are the 3 commands that can be used with ALTER

A

1) ADD
2) MODIFY
3) DROP

37
Q

What do constraints do?

A

Throw exceptions

38
Q

What are the two ways to specify constraints?

A

1) Column

2) Table

39
Q

Which type of constraint can ONLY be specified through a column constraint?

A

NOT NULL

40
Q

What are the 5 types of constraints?

A

1) Primary Key
2) Foreign Key
3) Unique
4) Check
5) NOT NULL

41
Q

What is the syntax for a primary key table constraint?

A

CONSTRAINT table_name_column_PK PRIMARY KEY(column)

42
Q

What is the syntax for a foreign key table constraint?

A

CONSTRAINT table_name_column_FK FOREIGN KEY (column) REFRENCES refrenced_table (column)

43
Q

What is the syntax for a unique table constraint?

A

CONSTRAINT table_name_column_UK UNIQUE(column)

44
Q

What is the syntax for a check constraint?

A

CONSTRAINT table_name_column_CK CHECK(boolean check)

45
Q

What is the syntax for table creation?

A
CREATE TABLE table_name
(
     column_name DATATYPE,
     column_name DATATYPE,
     CONSTRAINT 
);
46
Q

What is the syntax for an INSERT statement?

A

INSERT INTO table_name(column1, column2…column(n)) VALUES(value1, value2, … value(n))