How to add, delete and modify fields in Oracle

Time:2020-10-1

Oracle is one of the most popular databases. It has powerful function and excellent performance, so it is difficult to learn. This article is to share some of my experience with you, to accumulate, to facilitate myself and other learners.

Modify the field type or length:

Alter table name modify field name segment type (field length)

For example:


alter table table_name modify column_name varchar (10);

This is standard SQL and is applicable to any database

Modify field name:

Alter table name rename column old field name to new field name

For example:


alter table table_name rename column old_column to new_column;

Add fields:

Alter table name add (field name, segment type and length)


alter table table_name add(one_column varchar2(10));

If you add more than one field at a time, each field is directly separated by.

Here are some examples:


alter table table_name add(one_column varchar2(10),two_column varchar2(5),....)

 

Delete field:

Alter table name drop (field name)

alter table table_ name drop(one_ Column); or alter table table table_ name drop column
one_column;

Delete more than one field at a time, in brackets, and separate each field with.

Here are some examples:


alter table table_name drop(one_column,two_column,...)

summary

The above is the summary of oracle on the field of all the contents of the statement, I hope to help you. If you have any questions or questions, you can leave a message.