1.8 Inserting, updating, and deleting rows Flashcards

1
Q

INSERT

A

The INSERT statement adds rows to a table.

INSERT TableName (Column1, Column2, …)

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

INSERT INTO

A

The INSERT INTO clause names the table and columns where data is to be added. The keyword INTO is optional.
If all columns are added, as long as they are listed in order, the column names are optional. EX: if there is an auto incremented column, since this one cannot be added, you have to list the column names.

INSERT [INTO] TableName (Column1, Column2, …)
VALUES (Column1Val, Column2Val, …)

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

VALUES clause

A

The VALUES clause specifies the column values to be added.

Column names can be omitted as long as the VALUES clause lists all column values in the table’s column order

This
INSERT INTO Employee (ID, Name, Salary)
VALUES (2538, ‘Lisa Ellison’, 45000);

Turns to this:

INSERT INTO Employee
VALUES (5384, ‘Sam Snead’, 30500);

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

DEFAULT

A

The optional DEFAULT keyword and default value follow the column name and data type in a CREATE TABLE statement. The column is assigned the default value, rather than NULL, when omitted from an INSERT statement.

BirthDate DATE DEFAULT ‘2000-01-01’

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

UPDATE

A

The UPDATE statement modifies existing rows in a table.

UPDATE TableName
SET Column1 = Value1, Column2 = Value2, …
WHERE condition;

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

SET

A

The UPDATE statement uses the SET clause to specify the new column values.

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

DELETE

A

The DELETE statement deletes existing rows in a table.

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

FROM

A

The FROM keyword is followed by the table name whose rows are to be deleted.

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

TRUNCATE

A

The TRUNCATE statement deletes all rows from a table.

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