Get the App
SLTechnology News&Howtos  ›  Database  › 

How mysql modifies column

Shulou Source: shulou.com Published: 2022-05-31 10:41:01 11月01日 Update

This article mainly introduces the relevant knowledge of "how mysql modifies column". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to modify column in mysql" can help you solve the problem.

Methods: 1, modify the data type with "alter table table name modify column column name dateType" statement; 2, use "alter table table name change old column name new column name type (length)" statement to modify the name.

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How does mysql modify column

1. Modify the data type of the field

Alter table table_name modify column column_name dateType

Examples are as follows:

2. Modify the field name

Alter table table_name change old_column_name new_column_name int (11)

Expand knowledge:

1. Add a unique key

Alter table table_name add unique key `uniq_ column` (`column`)

2. Add a field

Alter table table_name add column column_name datatype

3. Delete a field

ALTER TABLE table_name DROP COLUMN column_name

4. Add columns

-alter table students add column column name column attribute alter table students add column language varchar (4) NOT NULL

-added to the end of the column by default

The after column name is added after the specified column name

FIRST is added to the first column

Note: the mysql5.7.16 version does not seem to support SECOND,THIRD...

Alter table students add column Mathematical varchar (4) NOT NULL after birth date

5. Delete columns

-alter table table name drop column lists alter table students drop column scores; this is the end of the introduction on "how mysql modifies column". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Fields knowledge types data methods versions industries statements different practical content names practicalities practical attributes scores tutorials mathematics articles dates Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker vpn Microsoft macOS OPPO Reno