SQL Tutorial: ALTER TABLE and drop

Source: Internet
Author: User
Tags sql tutorial

Change the statement of a table
ALTER table related declarations 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 are not allowed to delete a column): ALTER TABLE table_name DROP column column_name

To change the data type column in a table, use the following syntax: ALTER TABLE table_name ALTER COLUMN COLUMN_NAME datatype

Okay, now let's take a look at how SQL drop is used.
SQL drop INDEX, drop TABLE, and drop DATABASE

Indicators, tables and databases can easily be deleted/canceled with the drop spoke. The declining indicator of the index decline indicates that it 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 Inde X_name
 
DROP index Syntax for mysql:alter TABLE table_name DROP index index_name
 
with Dr The OP deletes the table as follows.

 
Drop TABLE table_name
 
with DROP database.
 
DROP DATABASE database_name
&NBSP
Truncate the declaration of the table if we only want to delete the data table, not the table itself? Then, use the TRUNCATE 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.