Database Reference
In-Depth Information
Figure 18.20
Cannot Add a
Non-nullable
Column to a
Nonempty Table.
Note: The CHAR(10) datatype was used for the new RELEASE_MONTH
column because the length of the value to be placed in this column is known,
the longest value being “September.” Using a VARCHAR2(10) datatype
would be misleading. VARCHAR2 datatypes are intended for storing vari-
able-length strings of up to 4,000 characters.
Look at the results, shown in Figure 18.21, by executing these com-
mands. The SELECT DISTINCT statement simply retrieves a month of
release for each individual CD.
SET WRAP OFF HEADING OFF;
DESC RELEASESIN2001;
SELECT DISTINCT CD||' was released in '
||RELEASE_MONTH "Month of Release"
FROM RELEASESIN2001;
We added a column to the RELEASESIN2001 table, and then we put
some data into it and finally modified the column to be non-nullable. To
remove the column added, type the ALTER TABLE command shown as
follows. You can execute the DESC RELEASESIN2001; command again
to make sure that the column RELEASE_MONTH has been dropped.
ALTER TABLE RELEASESIN2001 DROP (RELEASE_MONTH);
Take another look at the ALTER TABLE syntax diagram in Figure
18.18. Here are some points regarding column changes:
Search WWH ::




Custom Search