Home  >  Article  >  Database  >  How to modify the field order in Oracle

How to modify the field order in Oracle

WBOY
WBOYOriginal
2022-05-31 11:53:5411426browse

Method: 1. Use the select statement to match the user name and table name to query the table ID, and find out the order of all fields in the table through the ID; 2. Use "update sys.col$ set col#=3 where The obj#='table id' and name='field name'" statement can modify the field order.

How to modify the field order in Oracle

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

How to modify the field order in oracle

1. Query the ID of the table that needs to be changed

First requires sys or system permissions

select object_id
from all_objects
where owner = '当前用户名'
and object_name = '表名';

The example is as follows:

How to modify the field order in Oracle

Note: ITHOME is the user, TEST is the table to be changed, the table name should be in uppercase letters

Find out all fields of the table through ID The sequence of

select obj#, col#, name
from sys.col$
where obj# = '第一步的object_id' order by col#;

is as follows:

How to modify the field order in Oracle

2. The modification sequence of

update sys.col$ set col#=3 where obj#='第一步的object_id' and name='要修改的字段名称';

is as follows:

How to modify the field order in Oracle

Or directly add for update after the statement in the third step to modify it

Finally commit and restart the Oracle service

Recommended tutorial : "Oracle Video Tutorial"

The above is the detailed content of How to modify the field order 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