sql> create table test01 (no number not null,name varchar (30)); 1. Modify the table name SQL> alter table test01 rename to test02; Table altered. Sql> desc test01error:ora-04043: object test01 does not existsql> desc test02 Name Null? Type ----------------------------- ------------ -------- ---------------------------- NO not null number name                VARCHAR2 () 2. Changing table column names sql> alter table test01 rename column no to nod; Table altered. sql> desc test01 name Null? Type ----------------- ------------------------ -------- ---------------------------- NOD & nbsp; not null number name                VARCHAR2 (30) 3. Modify the Nod field type for table test01 sql> alter table test01 modify nod char; Table altered. sql> desc test01 name Null? Type ----------------- ------------------------ -------- ---------------------------- NOD not null char (1) NAME            VARCHAR2 (30) 3. Add a single deptsql> to table test01 ALTER TABLE TEST01 ADD DEPT VARCHAR2 (100); Table altered. sql> desc test01 name Null? Type ----------------- ------------------------ -------- ---------------------------- NOD not null char (1) NAME        VARCHAR2 () DEPT     VARCHAR2 (100) 4. Add multiple columns to table test01 Sex,agessql> alter table test01 add (Sex char (2), aGes number); Table altered. sql> desc test01 name Null? Type ----------------- ------------------------ -------- ---------------------------- NOD not null char (1) NAME varchar2(+) DEPT              VARCHAR2 ( SEX ) char (2) AGES number5. Add and modify columns for table test01 at the same time Sql> desc test01 name Null? Type ----------------------------------------- -------- --------------------------- - nod not null char (1) NAME     VARCHAR2 () DEPT               VARCHAR2 ( SEX) char (2) AGES NUMBERSQL> alter table test01 add (New01 char,new02 char) 2 modify (nod number,name number,dept number ,sex numbEr,ages char); Table altered. sql> desc test01 name Null? Type ----------------- ------------------------ -------- ---------------------------- NOD not NULL NUMBER NAME number dept NUMBER SEX NUMBER AGES char (1) NEW01 char (1) NEW02 char (1) 6.*** table test01 column sql> alter table test01 drop column dept cascade constraints;alter table test01 Drop column dept cascade constraints*error at line 1:ora-12988: cannot drop column from table owned by sys because my watch is a column of tables created under SYS and cannot be ***sys, other users can refer to the The following commands table column Sql > alter table scott.test01 drop column under the Scott user dept cascade constraints;
This article is from the "O Record" blog, so be sure to keep this source http://evils798.blog.51cto.com/8983296/1420890