Home  >  Article  >  Database  >  What is the command to modify the table structure in sql statement?

What is the command to modify the table structure in sql statement?

步履不停
步履不停Original
2019-06-14 16:28:1829052browse

What is the command to modify the table structure in sql statement?

The command in the SQL statement to modify the table structure is ALTER TABLE.

ALTER TABLE statement

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.

SQL ALTER TABLE syntax

To add columns to the table, please use the following syntax:

ALTER TABLE table_name
ADD column_name datatype

To delete columns in the table, please use the following syntax (Please note that some database systems do not allow this way of deleting columns in database tables):

ALTER TABLE table_name
DROP COLUMN column_name

To change the data type of a column in a table, use the following syntax:

SQL Server / MS Access:

ALTER TABLE table_name
ALTER COLUMN column_name datatype

My SQL / Oracle:

ALTER TABLE table_name
MODIFY COLUMN column_name datatype

Oracle 10G and later versions:

ALTER TABLE table_name
MODIFY column_name datatype;

For more SQL-related technical articles, please visit SQL tutorial column to learn!

The above is the detailed content of What is the command to modify the table structure in sql statement?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn