http://www.dba-oracle.com/t_alter_table_modify_column_syntax_example.htm

 

For complete tips on Oracle alter table syntax, see the book "Easy Oracle Jumpstart".  Oracle provides "alter table" syntax to modify data columns in-place in this form:

alter table
   table_name
modify
   column_name  datatype;

If you are brave you can use a single "alter table" syntax to modify multiple columns:

alter table
   table_name
modify
   (
   column1_name  column1_datatype,
   column2_name  column2_datatype,
   column3_name  column3_datatype,
   column4_name  column4_datatype
   );

Here are some examples of Oracle "alter table" syntax to modify data columns and note that you can add constraints like NOT NULL:

ALTER TABLE 
   customer 
MODIFY 
   ( 
   cust_name varchar2(100) not null,
   cust_hair_color  varchar2(20)
   )
;

We can also use Oracle "alter table" syntax in dynamic PL/SQL to modify data columns

BEGIN 
SQL_STRING := 'ALTER TABLE '||:TABLE_NAME||' MODIFY '||:COLUMN_NAME||' VARCHAR2(100)';
 . . . 
END;
 

相关文章:

  • 2022-12-23
  • 2022-01-09
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
猜你喜欢
  • 2021-11-29
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2021-11-13
  • 2022-02-24
相关资源
相似解决方案