How to modify the field order of Oracle in PL/SQL

Source: Internet
Author: User

This afternoon work encountered problems, I need to put the data in a table in its backup table a_1, but the a_1 table is missing two fields, so I will add two fields, but the new field will default to the last side, and table A in the order of the field is inconsistent, then insert into a_1 SELECT * from A; Will go wrong.

A stupid method was used, as follows:

--Create a new temporary table to store the correct order

CREATE TABLE a_2 as select (column1,colum2,...... The Order in table a) from a_1;

--Delete Table a_1

drop table a_1;

--Create a new a_1 and give it the correct order and value from the a_2 table

CREATE TABLE A_1 as SELECT * from a_2;

--Delete temporary table a_2

drop table a_2;

=============

Method Two: It seems that only administrators have permission to modify

1. First, log on PL/SQL as the SYS user

2. To find out the ID of the table you want to change, take my local data for example, I want to change the ' finace ' user under the ' INCOME ' table. Note: The tables in Oracle are capitalized.

Select object_id

From All_objects

where owner = ' finace ' and

object_name = ' INCOME ';

3. Query the field in the table and the field ordinal according to the ID

Select Obj#,col#,name

From sys.col$

where obj#=73626;

For update

How to modify the field order of Oracle in PL/SQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.