SQL Command to Add Columns to a Table
The correct command to add columns to a table in SQL is 'alter'.
Here's why:
- alter is used to modify the structure of an existing table, including adding new columns.
- truncate removes all rows from a table but keeps the table structure intact.
- insert adds new rows to a table with existing columns.
- drop deletes an entire table and its data.
Example:
To add a column named 'email' to a table called 'users', you would use the following SQL statement:
ALTER TABLE users ADD email VARCHAR(255);
This command will add a new column named 'email' to the 'users' table. The column will be of type VARCHAR and have a maximum length of 255 characters.

原文地址: http://www.cveoy.top/t/topic/oCmo 著作权归作者所有。请勿转载和采集!