Modify tables, add columns, delete columns, and modify columns in oracle

Source: Internet
Author: User

Modify tables, add columns, delete columns, and modify columns in oracle
1. Add Columns
Alter table table_name ADD (column datatype [default expr] [, column datatype...]);
For example:
SQL> ALTER TABLE emp01 ADD eno NUMBER (4 );
 
2. Modify column Definitions
For example:
SQL> ALTER TABLE emp01 MODIFY job VARCHAR2 (15)
2 DEFAULT 'cler'
 
3. Delete Columns
For example:
SQL> ALTER TABLE emp01 DROP COLUMN dno;
 
4. Modify the column name
For example:
SQL> ALTER TABLE emp01 RENAME COLUMN eno TO empno;
 
5. Modify the table name
For example:
SQL> RENAME emp01 TO employee;
 
6. Add comments
For example:
SQL> COMMENT ON TABLE employee IS 'employee information ';
SQL> COMMENT ON TABLE employee. name IS 'employee name ';

7. Evaluate the length of the field ()
For example:
Select t. * from tp_area t where substr (t. area_id,) = '03' and length (t. area_id)> 2

Related Article

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.