Home > Database > Oracle > body text

How to increase field length in oracle

WBOY
Release: 2022-03-07 14:39:08
Original
30098 people have browsed it

In Oracle, you can use the alter statement with modify to increase the field length. Modify is used to modify the field type and length, that is, to modify the attributes of the field. The syntax is "alter table table name modify (field name field type) ".

How to increase field length in oracle

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

How to increase the field length in oracle

Scenario: The field length of a certain table in the project is not enough, and now it is necessary to increase its length

There are two situations:

1. When there is no data in the table, it can be solved with just one sql statement.

alter     table    表名    modify(字段名   字段类型 )
Copy after login

Example:

alter table A modify(name varchar2(4000))
Copy after login

2. When there is data in the table, it is also very simple. As a small idea, first change the name of the original field, and then add a new column. The new column name is consistent with the original field column name, and then copy the data in the original field into the new field

Create a C table, the corresponding name field length is 100, now we need to increase the field length if it has data

Rename the name column to names

Changed to names

Add a name field. At this time, the data type or length of this name, Just change it to the field length or type you want. Here, change it to 4000

Copy the data to the newly created column

Delete the names field,


Then it’s OK

Recommended tutorial: "Oracle Video Tutorial

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template