Home  >  Article  >  Database  >  How to modify column length in oracle

How to modify column length in oracle

WBOY
WBOYOriginal
2022-05-13 10:48:5521469browse

In Oracle, you can use modify with the "alter table" statement to modify the length of the column. The function of modify is to modify the field type and length, that is, to modify the attributes of the field. The syntax is "alter table table name modify The field length of the column name field type needs to be modified."

How to modify column length in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

How to modify the column length in oracle

modify modifies the field type and length, that is, modifies the attributes of the field.

ALTER TABLE table_name 
MODIFY column_name action;

The statement is very straightforward. To modify the columns of a table, you need to specify the column name, table name and operation to be performed. Database

Oracle allows you to perform a variety of operations, but the following are the main commonly used operations: oracle

  • Modify the visibility of a column

  • Allow or disallow NULL values

  • Shorten or expand the size of a column

  • Change the default value of a column

  • Modify the expression of virtual column

alter table 表名 modify column_name varchar2(32)

Standard SQL statement to modify field type and length:

ALTER TABLE tableName modify column columnName 类型;

For example, Mysql's statement to modify field type :

alter table test modify column name varchar(255);

Oracle statement to modify field type and length:

ALTER TABLE tableName modify(columnName 类型);

For example

alter table test modify(name varchar(255));

Oracle statement to modify multiple field types and lengths:

alter table 表名 modify (column_name1 varchar(20) default null,column_name2 varchar2(30));
alter table 表名 modify column_name varchar2(32)

Recommended tutorial : "Oracle Video Tutorial"

The above is the detailed content of How to modify column length in oracle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn