Sqlalert Modify Table or add Column

Source: Internet
Author: User
The alert command of SQL is used to modify the data table name, add columns, delete columns, and modify the field data type. now let's look at the instances one by one. to add a column to a table in database ALTERTABLE syntax, use the following syntax: ALTERTABLEtable_nameADDcolumn_namedatatype to view the instance of the added instance: the alert command of ALTERTABLEtnameALTERCOLUMNdata SQL is used to modify the table name, add columns, and delete columns, modify the field data type. now let's look at the instances one by one.

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

ALTER TABLE table_name  ADD column_name datatype
Let's take a look at the added instance:
ALTER TABLE tname  ALTER COLUMN data year
 
This adds a year field of the data type to the tname table.
The above is the syntax for adding columns in the Table. Let's take a look at deleting columns. drop column column_name
ALTER TABLE table_name DROP COLUMN column_name
Let's seeDelete columnInstance.
ALTER TABLE Persons DROP COLUMN DateOfBirth
Modify the field type again:
 ALTER COLUMN column_name datatype _id order by w_support desc
P_Id  LastName   FirstName  Address City 
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
Please note:

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.