创建表: SQL> create table test(id number,name varchar2(10));Table created显示表结构: SQL> desc test; Name Type Nullable Default Comments ---- ------------ -------- ------- -------- ID NUMBER Y NAME VARCHAR2(10) Y 删除字段name: SQL> alter table test drop column name;Table altered显示表结构: SQL> desc test; Name Type Nullable Default Comments ---- ------ -------- ------- -------- ID NUMBER Y 添加字段name: SQL> alter table test add name varchar2(10);Table altered重命名字段name为re_name: SQL> alter table test rename column name to re_name;Table altered显示表结构: SQL> desc test Name Type Nullable Default Comments ------- ------------ -------- ------- -------- ID NUMBER Y RE_NAME VARCHAR2(10) Y 注:以上测试是在Oracle 9i中通过的,并且在表中没有数据的情况下。在表中有数据的情况下的测试: SQL> insert into test values(1,'a');1 row insertedSQL> insert into test values(1,'b');1 row insertedSQL> insert into test values(1,'c');1 row insertedSQL> commit;Commit completeSQL> select * from test; ID RE_NAME ---------- ---------- 1 a 1 b 1 c SQL> alter table test drop column re_name;Table alteredSQL> select * from test; ID ---------- 1 1 1 SQL> alter table test add name varchar2(10);Table alteredSQL> select * from test; ID NAME ---------- ---------- 1 1 1 SQL> alter table test rename column name to re_name;Table alteredSQL> select * from test; ID RE_NAME ---------- ---------- 1 1 1 由以上测试后,对 一、选择题(5) 1. 下面哪个基于表的操作在ORACLE中是不允许的 A. 增加一个字段 B. 给一个存在的字段重新命名 C. 删除一个已经存在的字段 D. 以上都是该怎么选择,大家就看着办吧!!!
对上面的测试再加一个对字段有值的重命名: SQL> select * from test; ID RE_NAME ---------- ---------- 1 a 1 b 1 c SQL> alter table test rename column re_name to name;Table alteredSQL> select * from test; ID NAME ---------- ---------- 1 a 1 b 1 c
SQL> create table test(id number,name varchar2(10));Table created显示表结构:
SQL> desc test;
Name Type Nullable Default Comments
---- ------------ -------- ------- --------
ID NUMBER Y
NAME VARCHAR2(10) Y 删除字段name:
SQL> alter table test drop column name;Table altered显示表结构:
SQL> desc test;
Name Type Nullable Default Comments
---- ------ -------- ------- --------
ID NUMBER Y 添加字段name:
SQL> alter table test add name varchar2(10);Table altered重命名字段name为re_name:
SQL> alter table test rename column name to re_name;Table altered显示表结构:
SQL> desc test
Name Type Nullable Default Comments
------- ------------ -------- ------- --------
ID NUMBER Y
RE_NAME VARCHAR2(10) Y 注:以上测试是在Oracle 9i中通过的,并且在表中没有数据的情况下。在表中有数据的情况下的测试:
SQL> insert into test values(1,'a');1 row insertedSQL> insert into test values(1,'b');1 row insertedSQL> insert into test values(1,'c');1 row insertedSQL> commit;Commit completeSQL> select * from test; ID RE_NAME
---------- ----------
1 a
1 b
1 c
SQL> alter table test drop column re_name;Table alteredSQL> select * from test; ID
----------
1
1
1
SQL> alter table test add name varchar2(10);Table alteredSQL> select * from test; ID NAME
---------- ----------
1
1
1 SQL> alter table test rename column name to re_name;Table alteredSQL> select * from test; ID RE_NAME
---------- ----------
1
1
1 由以上测试后,对
一、选择题(5)
1. 下面哪个基于表的操作在ORACLE中是不允许的
A. 增加一个字段
B. 给一个存在的字段重新命名
C. 删除一个已经存在的字段
D. 以上都是该怎么选择,大家就看着办吧!!!
SQL> select * from test; ID RE_NAME
---------- ----------
1 a
1 b
1 c
SQL> alter table test rename column re_name to name;Table alteredSQL> select * from test; ID NAME
---------- ----------
1 a
1 b
1 c
下面哪个基于表的操作在ORACLE的(版本)中是不允许的 版本不同不一样啊.