SQL Tutorial: ALTER TABLE and drop

Source: Internet
Author: User
Tags sql tutorial

Change table Declaration
Alter table statements are used to add, delete, or modify columns in an existing TABLE.

Database alter table syntax
To add a column to a table, use the following syntax:

Alter table table_name ADD column_name datatype
To delete a COLUMN in a TABLE, use the following syntax (notification, some database systems cannot delete a COLUMN): alter table table_name drop column column_name
 
To change the data type of a COLUMN in a TABLE, use the following syntax: alter table table_name alter column column_name datatype
 
Now let's take a look at the use of SQL drop.
SQL DROP INDEX, DROP TABLE, and DROP DATABASE
 
Indicators, tables, and databases can be easily deleted/removed from the same drop-down statement. The index drop statement indicates that the index drop is used to delete the index table. Drop index syntax for MS Access: drop index index_name ON table_name
 
The drop index syntax is ms SQL Server:

Drop index table_name.index_name
 
Drop index Syntax for DB2/Oracle:
Drop index index_name
 
Drop index Syntax for MySQL: alter table table_name drop index index_name
 
Use drop to delete a table as follows.

 
Drop table table_name
 
Use drop database.
 
Drop database database_name
 
What if we only want to delete the data table, not the table itself? Then, use the truncation TABLE statement

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.