(NuC) Database Manipulation: SQL

CREATE, INSERT, ALTER TABLE, UPDATE, DELETE & DROP

Kenny Hin
Aug 14, 2022

CREATE

INSERT

Where is the ID? Peep next slide: SERIAL

Each time INSERT is implemented — “id SERIAL” will increment column integer.

Returns ERROR

JEEP value need to be integer, peep the CREATE TABLE.

ALTER TABLE

Used to modify table

ERROR: Table already has rows present, we need to reconcile what the wheel_count should be for existing rows.

default value

omitting default values in INSERT.

overriding default values

Notice:

Year was not included in INSERT parameter, therefor is NULL value.

UPDATE

DELETE AND DROP

IS acts as boolean. Notice deleted column /row 4

On delete

The problem with delete:

Solutions

Cascade

SET NULL

SET DEFAULT

Which is most reasonable?

There will be tradeoffs with each. Although cascade is the most reasonable in this scenario.

Other options:

--

--