Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Modifying columns
3. Changing column type – 1
Modifying identities
Modifying sequences
Summary

Instruction

The query failed because the title we tried to add was too long. Note that other databases may behave differently: they will accept longer values or they will trim the value and only accept the first x characters. Either way, we'll have a problem with longer values in most databases. Can we do anything about this? Luckily, SQL allows us to change column types. Take a look:

ALTER TABLE artwork ALTER COLUMN title SET DATA TYPE varchar(128);

In the query above, we make the title column longer by changing its type to varchar(128). It will keep all existing data intact.

Let's see this in practice.

Exercise

Run the template code and see what happens.