Changing the Size of a Column

The following ALTER TABLE statement increases the maximum length of the emp.ename column to 15 characters:


SQL> CREATE TABLE EMP (EMPNO NUMBER(4) NOT NULL,
  2                    ENAME VARCHAR2(10),
  3                    JOB VARCHAR2(9),
  4                    SAL NUMBER(7, 2),
  5                    DEPTNO NUMBER(2));

Table created.

SQL>
SQL> ALTER TABLE emp
  2  MODIFY ename VARCHAR2(15);

Table altered.

SQL> desc emp
 Name                                      Null?    Type
 ----------------------------------------- -------- -----------------
 EMPNO                                     NOT NULL NUMBER(4)
 ENAME                                              VARCHAR2(15)
 JOB                                                VARCHAR2(9)
 SAL                                                NUMBER(7,2)
 DEPTNO                                             NUMBER(2)

SQL>

You can decrease the length of a column if table is empty or all the rows contain null values for that column.

Home »
Oracle »
Table » 

Column:
  1. Adding a Column
  2. Adding a Virtual Column
  3. Changing the Size of a Column
  4. Changing the Precision of a Numeric Column
  5. Changing the Data Type of a Column
  6. Changing the Default Value of a Column
  7. Dropping a Column
Related: