Oracle uses alter to modify the table element code

Source: Internet
Author: User

The following articles mainly describe the actual application code for Oracle to use alter to modify table elements. If you are curious about the actual operation of Oracle to use alter to modify table elements, the following articles will unveil its mysteries. I hope you will gain some benefits after browsing.

Add field c

 
 
  1. alter table docdsp add dspcode char(200) 

Delete Field

 
 
  1. ALTER TABLE table_NAME DROP COLUMN column_NAME 

Modify Field Type

 
 
  1. ALTER TABLE table_name ALTER COLUMN column_name new_data_type 

Rename

 
 
  1. sp_rename 

Change the name of a user-created object, such as a table, column, or user-defined data type, in the current database.

Syntax

 
 
  1. sp_rename [ @objname = ] 'object_name' ,  
  2. [ @newname = ] 'new_name'  
  3. [ , [ @objtype = ] 'object_type' ]  

Set primary key

 
 
  1. alter table yourtable add constraint PK_ID primary key(ID) 


The above content is an introduction to Oracle's use of alter to modify table elements.

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.