In mysql, you can use the "ALTER TABLE" statement to add a column to the original table. The syntax format is "ALTER TABLE data table name ADD field name field type"; this statement is used to add a column to an existing table. Add, modify, or delete columns.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
ALTER TABLE table_name ADD column_name datatype
(The table name cannot be table, this is a reserved word. After ADD, the added column name and data type are added)
ALTER TABLE statement Used to add, modify or delete columns in an existing table.
To drop a column from a table, use the following syntax:
ALTER TABLE table_name DROP COLUMN column_name
Note: Some database systems do not allow this way of dropping a column in a database table (DROP COLUMN column_name).
To change the data type of a column in the table, please use the following syntax:
ALTER TABLE table_name ALTER COLUMN column_name datatype
Related recommendations: "mysql tutorial"
The above is the detailed content of How to add a column to the original table in sql. For more information, please follow other related articles on the PHP Chinese website!