首页 » ORACLE 9i-23ai » oracle 修改列的前后顺序

oracle 修改列的前后顺序

Whether you are create table or alter  table plus a filling, the column is asequence of before and after,In oracle you can modify the sequence.

for example:

SQL>create table testcol(id number(3),
id2 int,
id1 int);

Table created.

SQL> select obj#,name from obj$ where name=’TESTCOL’;

OBJ# NAME
———- ——————————
50705 TESTCOL

SQL> DESC TESTCOL;
Name                                                    Null?    Type
————————————————————— ——–

ID                                                               NUMBER(3)
ID2                                                              NUMBER(38)
ID1                                                              NUMBER(38)

SQL> desc col$;
Name                                                             Null?    Type
———————————————————————— ——–

OBJ#                                                             NOT NULL NUMBER
COL#                                                             NOT NULL NUMBER
SEGCOL#                                                          NOT NULL NUMBER
SEGCOLLENGTH                                                     NOT NULL NUMBER
OFFSET                                                           NOT NULL NUMBER
NAME                                                             NOT NULL VARCHAR2(30)
TYPE#                                                            NOT NULL NUMBER
LENGTH                                                           NOT NULL NUMBER
FIXEDSTORAGE                                                     NOT NULL NUMBER
PRECISION#                                                                NUMBER
SCALE                                                                     NUMBER
NULL$                                                            NOT NULL NUMBER
DEFLENGTH                                                                 NUMBER
DEFAULT$                                                                  LONG
INTCOL#                                                          NOT NULL NUMBER
PROPERTY                                                         NOT NULL NUMBER
CHARSETID                                                                 NUMBER
CHARSETFORM                                                               NUMBER
SPARE1                                                                    NUMBER
SPARE2                                                                    NUMBER
SPARE3                                                                    NUMBER
SPARE4                                                                    VARCHAR2(1000)
SPARE5                                                                    VARCHAR2(1000)
SPARE6                                                                    DATE

SQL> select obj#,col#,name from col$ where obj#=50705;

OBJ#       COL# NAME
———- ———- ——————————
50705          1 ID
50705          2 ID2
50705          3 ID1

SQL> update col$ set col#=2 where obj#=50705 and name=’ID1′;

1 row updated.

SQL> update col$ set col#=3 where obj#=50705 and name=’ID2′;

1 row updated.

SQL> COMMIT;

Commit complete.

SQL> select obj#,col#,name from col$ where obj#=50705;

OBJ#       COL# NAME
———- ———- ——————————
50705          1 ID
50705          3 ID2
50705          2 ID1

SQL> desc testcol;
Name                                         Null?    Type
—————————————————- ——–

ID                                                    NUMBER(3)
ID2                                                   NUMBER(38)
ID1                                                   NUMBER(38)

SQL> select * from testcol;

no rows selected

SQL> alter system flash shared_pool;
alter system flash shared_pool
*
ERROR at line 1:
ORA-02065: illegal option for ALTER SYSTEM
SQL> alter system flush shared_pool;

System altered.

SQL> select * from testcol;

no rows selected

SQL> desc testcol;
Name                                         Null?    Type
—————————————————- ——–

ID                                                    NUMBER(3)
ID1                                                   NUMBER(38)
ID2                                                   NUMBER(38)

SQL> insert into testcol values(1,2,3);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from testcol;

ID        ID1        ID2
———- ———- ———-
1          2          3

SQL>

打赏

目前这篇文章有17条评论(Rss)评论关闭。

  1. Breanne Sauve | #1
    2011-12-13 at 21:29

    Please note are perfect, I’ll employ them right now. Cheers!

  2. iphone apps and themes | #2
    2011-11-17 at 14:18

    I’m usually to help posting and I also truly enjoy your articles. This post has really peaks my personal interest. Intending to store your web page and preserve looking at for company fresh details.

  3. Daisey Erceg | #3
    2011-08-10 at 14:48

    Blasphemy! Lmao Merely simply kidding. Ive read same details on alternative websites. I most certainly will acquire your idea for it. Be reliable! the buddy.

  4. Indy | #4
    2011-06-17 at 20:01

    Wow, that’s a ralley clever way of thinking about it!

  5. 万嗔 | #5
    2011-05-20 at 10:31

    哇塞,真的可以!这个能用到正式环境么。
    alter system flush shared_pool 会对比的有啥影响不。

    • admin | #6
      2011-05-23 at 11:05

      可以,不过解析过的sql都没了也就是lib chach受到影响

      • Dollie | #7
        2011-06-16 at 08:37

        Great cmoomn sense here. Wish I’d thought of that.

        • Rose | #8
          2011-06-22 at 15:28

          There’s a srecet about your post. ICTYBTIHTKY

      • Jessie | #9
        2011-06-16 at 11:10

        Kewl you slohud come up with that. Excellent!

        • Fidelia | #10
          2011-06-23 at 01:08

          No more s***. All posts of this qlaiuty from now on

    • Josie | #11
      2011-06-16 at 15:18

      Hey, good to find someone who ageers with me. GMTA.

      • Judith | #12
        2011-06-23 at 05:20

        Hey, that post leaves me feeling floosih. Kudos to you!

    • Gracelin | #13
      2011-06-16 at 15:18

      And I thought I was the sensible one. Thanks for setntig me straight.

      • Vinny | #14
        2011-06-23 at 08:57

        That saves me. Thanks for being so snesilbe!

    • Alla | #15
      2011-06-16 at 17:56

      Now we know who the snesible one is here. Great post!

      • Chelsia | #16
        2011-06-23 at 08:21

        Now I’m like, well duh! Truly thnakufl for your help.