Operations for Oracle Table TEST01 fields

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.