Databases and SQL Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Give the format for creating a table.

A

CREATE TABLE (name)
(
Attribute1, INT(numDigits), PRIMARY KEY
Attribute2,VARCHAR(numCharacters)/TEXT, FOREIGN KEY
Attribute3, DATE
)

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

Give the format for adding values into a table.

A

INSERT INTO (name)
VALUES (‘value1’,’value2’,’value3’),
(‘value4’,’value5’,’value6’)

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

Give the format for updating values in a table.

A

UPDATE (name)
SET (Attribute2) = ‘value3’
WHERE (Attribute1) = ‘value1’

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

Give the format for deleting values in a table.

A

DELETE FROM (name)
WHERE (Attribute1) = ‘value1’

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

Give the format for selecting items/values.

A

SELECT *(everything) / (Attribute1), (Attribute2)
FROM (name)
WHERE (Attribute1) = ‘value1’ / > (value2)
ORDER BY (Attribute3) DESC # default is ascending

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

Give the line for selecting the first value from the first entity found.

A

SELECT DISTINCT (Attribute1)

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

What is the format for DATE?

A

YYYY-MM-DD

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

What is the format for TIME?

A

HH:MM:SS

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

What is the definition of a primary key?

A

An attribute/field which uniquely identifies a record.

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

What is the definition of a foreign key?

A

A attribute/field in one table which refers to the primary key in another table.

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