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) ".
The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.
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(字段名 字段类型 )
Example:
alter table A modify(name varchar2(4000))
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!