关闭

重命名列名和表名

1486人阅读 评论(0) 收藏 举报

SQL> create table test as select * from t_user;
SQL> desc test
 名称                                                  是否为空? 类型
 ----------------------------------------------------- -------- ------------------------------------
 USERID                                                NOT NULL NUMBER(38)
 LOGINID                                               NOT NULL VARCHAR2(20)
 NAME                                                           VARCHAR2(20)
 PASSWORD                                                       VARCHAR2(20)
 STATUS                                                         CHAR(1)
 EXPIREDDATE                                                    DATE
 MEMO                                                           VARCHAR2(50)
 EXCHANGEID                                            NOT NULL NUMBER(5)
 PASNUMBER                                                      VARCHAR2(20)

SQL> alter table test rename column name to name1;
SQL> desc test;
 名称                                                  是否为空? 类型
 ----------------------------------------------------- -------- ------------------------------------
 USERID                                                NOT NULL NUMBER(38)
 LOGINID                                               NOT NULL VARCHAR2(20)
 NAME1                                                          VARCHAR2(20)
 PASSWORD                                                       VARCHAR2(20)
 STATUS                                                         CHAR(1)
 EXPIREDDATE                                                    DATE
 MEMO                                                           VARCHAR2(50)
 EXCHANGEID                                            NOT NULL NUMBER(5)
 PASNUMBER                                                      VARCHAR2(20)

SQL> rename test to test1;
SQL> desc test;
ERROR:
ORA-04043: 对象 test 不存在


SQL> desc test1
 名称                                                  是否为空? 类型
 ----------------------------------------------------- -------- ------------------------------------
 USERID                                                NOT NULL NUMBER(38)
 LOGINID                                               NOT NULL VARCHAR2(20)
 NAME1                                                          VARCHAR2(20)
 PASSWORD                                                       VARCHAR2(20)
 STATUS                                                         CHAR(1)
 EXPIREDDATE                                                    DATE
 MEMO                                                           VARCHAR2(50)
 EXCHANGEID                                            NOT NULL NUMBER(5)
 PASNUMBER                                                      VARCHAR2(20)

SQL> spool off

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:23620次
    • 积分:429
    • 等级:
    • 排名:千里之外
    • 原创:20篇
    • 转载:0篇
    • 译文:0篇
    • 评论:1条
    最新评论
  • 指定临时表空间

    mengxb: oracle对临时表空间的使用原则为,只管增大,而不管缩小。 当有排序操作需要临时表空间时,系统就...

    T友