MODIFY statement is used to modify the table structure, including adding, deleting or modifying columns. The steps are as follows: Specify the table name to be modified. Specify the column name to be modified. Specifies the new data type of the column. Optional: Specify columns that do not allow null values. Optional: Specify the default value for the column.
Usage of MODIFY in SQL
Overview
MODIFY Statements are used in SQL to modify the table structure. It allows you to add, delete, or modify a table's columns.
Syntax
<code class="sql">MODIFY TABLE table_name MODIFY column_name data_type [NOT NULL] [DEFAULT default_value];</code>
Parameters
Usage
Modify column data type
<code class="sql">MODIFY TABLE customers MODIFY age INT;</code>
Add column
<code class="sql">MODIFY TABLE products ADD COLUMN description VARCHAR(255);</code>
Delete column
<code class="sql">MODIFY TABLE orders DROP COLUMN shipping_address;</code>
Modify column default value
<code class="sql">MODIFY TABLE employees MODIFY salary DECIMAL(10, 2) DEFAULT 1000;</code>
Note
The above is the detailed content of How to use modify in sql. For more information, please follow other related articles on the PHP Chinese website!