重命名列名和表名

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

阅读更多
文章标签: null sql date table user
个人分类: Oracle Develop
上一篇SQL优化
下一篇指定临时表空间
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭