Midterm Flashcards

(46 cards)

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?

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?

24
Q

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

A

Artificial Key

25
What is an artificial key?
A hidden key made up of a physical address (page# + fileid)
26
What keyword is used to delete a table?
DROP
27
What keyword is used to make a table?
CREATE
28
How many characters can a VARCHAR be?
8000
29
What is a VARCHAR datatype?
Variable length string
30
What's the difference between VARCHAR and CHAR?
CHAR adds padding to unused space
31
How do you specify an apostrophe when specifying a CHAR variable?
Two single quotes, NOT a double quote
32
How many bits in an INT?
32
33
How do you get the data dictionary?
INFORMATION_SCHEMA.
34
What is a data dictionary?
Metadata on the database
35
How do you create a table with a SELECT statement?
SELECT column INTO new_table FROM existing_table
36
What are the 3 commands that can be used with ALTER
1) ADD 2) MODIFY 3) DROP
37
What do constraints do?
Throw exceptions
38
What are the two ways to specify constraints?
1) Column | 2) Table
39
Which type of constraint can ONLY be specified through a column constraint?
NOT NULL
40
What are the 5 types of constraints?
1) Primary Key 2) Foreign Key 3) Unique 4) Check 5) NOT NULL
41
What is the syntax for a primary key table constraint?
CONSTRAINT table_name_column_PK PRIMARY KEY(column)
42
What is the syntax for a foreign key table constraint?
CONSTRAINT table_name_column_FK FOREIGN KEY (column) REFRENCES refrenced_table (column)
43
What is the syntax for a unique table constraint?
CONSTRAINT table_name_column_UK UNIQUE(column)
44
What is the syntax for a check constraint?
CONSTRAINT table_name_column_CK CHECK(boolean check)
45
What is the syntax for table creation?
``` CREATE TABLE table_name ( column_name DATATYPE, column_name DATATYPE, CONSTRAINT ); ```
46
What is the syntax for an INSERT statement?
INSERT INTO table_name(column1, column2...column(n)) VALUES(value1, value2, ... value(n))