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

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

步履不停
Release: 2019-06-19 16:05:44
Original
29092 people have browsed it

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
Copy after login

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
Copy after login

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
Copy after login

My SQL / Oracle:

ALTER TABLE table_name
MODIFY COLUMN column_name datatype
Copy after login

Oracle 10G and later versions:

ALTER TABLE table_name
MODIFY column_name datatype;
Copy after login

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!

Related labels:
sql
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template