Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify table fields in mysql

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Mysql how to modify the table field, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

-- modify table fields

CREATE TABLE register (

Id INT PRIMARY KEY AUTO_INCREMENT

Name VARCHAR (10) DEFAULT NULL UNIQUE KEY

Age tinyint UNSIGNED DEFAULT 18

RegisTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ()

Fund DOUBLE (9,2) DEFAULT 1000000.00

Tel CHAR (11) NOT NULL

);

-- change age to int, with a default value of 30

ALTER TABLE register MODIFY age int UNSIGNED DEFAULT 30th int-change the age of tinyint to the default unsigned int

Change age to tinyint default to 18, and put it in the first place

ALTER TABLE register MODIFY age tinyint UNSIGNED DEFAULT 18 FIRST

-- use alter to modify default values

ALTER TABLE register ALTER age SET DEFAULT 30

-- Delete default values

ALTER TABLE register ALTER age DROP DEFAULT

-- modify column names

ALTER TABLE register CHANGE COLUMN regisTime newTime TIMESTAMP

-- modify the table name

ALTER TABLE register RENAME register2

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report